Class: Cod::BidirPipe
Instance Attribute Summary collapse
-
#r ⇒ Object
readonly
The Cod::Pipe instance we’re currently #get’ting from.
-
#w ⇒ Object
readonly
The Cod::Pipe instance we’re currently #put’ting to.
Instance Method Summary collapse
- #close ⇒ Object
- #get ⇒ Object
-
#initialize(serializer = nil, pipe_pair = nil) ⇒ BidirPipe
constructor
A new instance of BidirPipe.
- #put(msg) ⇒ Object
-
#swap! ⇒ Object
Swaps the end of this pipe around.
Methods inherited from Channel
Constructor Details
#initialize(serializer = nil, pipe_pair = nil) ⇒ BidirPipe
Returns a new instance of BidirPipe.
8 9 10 11 |
# File 'lib/cod/bidir_pipe.rb', line 8 def initialize(serializer=nil, pipe_pair=nil) @serializer = serializer || SimpleSerializer.new @r, @w = pipe_pair || [Cod.pipe(@serializer), Cod.pipe(@serializer)] end |
Instance Attribute Details
#r ⇒ Object (readonly)
The Cod::Pipe instance we’re currently #get’ting from.
6 7 8 |
# File 'lib/cod/bidir_pipe.rb', line 6 def r @r end |
#w ⇒ Object (readonly)
The Cod::Pipe instance we’re currently #put’ting to.
4 5 6 |
# File 'lib/cod/bidir_pipe.rb', line 4 def w @w end |
Instance Method Details
#close ⇒ Object
21 22 23 24 |
# File 'lib/cod/bidir_pipe.rb', line 21 def close r.close w.close end |
#get ⇒ Object
17 18 19 |
# File 'lib/cod/bidir_pipe.rb', line 17 def get r.get end |
#put(msg) ⇒ Object
13 14 15 |
# File 'lib/cod/bidir_pipe.rb', line 13 def put(msg) w.put(msg) end |
#swap! ⇒ Object
Swaps the end of this pipe around.
28 29 30 |
# File 'lib/cod/bidir_pipe.rb', line 28 def swap! @r, @w = w, r end |