Class: Cod::IOPair
- Inherits:
-
Struct
- Object
- Struct
- Cod::IOPair
- Defined in:
- lib/cod/iopair.rb
Instance Attribute Summary collapse
-
#r ⇒ Object
Returns the value of attribute r.
-
#w ⇒ Object
Returns the value of attribute w.
Instance Method Summary collapse
- #close ⇒ Object
- #close_r ⇒ Object
- #close_w ⇒ Object
-
#initialize(r = nil, w = nil) ⇒ IOPair
constructor
A new instance of IOPair.
-
#initialize_copy(other) ⇒ Object
Performs a deep copy of the structure.
- #read(serializer) ⇒ Object
- #write(buf) ⇒ Object
Constructor Details
#initialize(r = nil, w = nil) ⇒ IOPair
Returns a new instance of IOPair.
3 4 5 6 7 8 9 |
# File 'lib/cod/iopair.rb', line 3 def initialize(r=nil, w=nil) if r && w super(r, w) else super(*IO.pipe) end end |
Instance Attribute Details
#r ⇒ Object
Returns the value of attribute r
2 3 4 |
# File 'lib/cod/iopair.rb', line 2 def r @r end |
#w ⇒ Object
Returns the value of attribute w
2 3 4 |
# File 'lib/cod/iopair.rb', line 2 def w @w end |
Instance Method Details
#close ⇒ Object
25 26 27 28 |
# File 'lib/cod/iopair.rb', line 25 def close close_r close_w end |
#close_r ⇒ Object
29 30 31 32 |
# File 'lib/cod/iopair.rb', line 29 def close_r r.close if r self.r = nil end |
#close_w ⇒ Object
33 34 35 36 |
# File 'lib/cod/iopair.rb', line 33 def close_w w.close if w self.w = nil end |
#initialize_copy(other) ⇒ Object
Performs a deep copy of the structure.
12 13 14 15 16 |
# File 'lib/cod/iopair.rb', line 12 def initialize_copy(other) super self.r = other.r.dup if other.r self.w = other.w.dup if other.w end |
#read(serializer) ⇒ Object
21 22 23 24 |
# File 'lib/cod/iopair.rb', line 21 def read(serializer) raise Cod::WriteOnlyChannel unless r serializer.de(r) end |
#write(buf) ⇒ Object
17 18 19 20 |
# File 'lib/cod/iopair.rb', line 17 def write(buf) raise Cod::ReadOnlyChannel unless w w.write(buf) end |