Class: JSCommander::PipeBroker::PipeQueue
- Inherits:
-
Object
- Object
- JSCommander::PipeBroker::PipeQueue
- Defined in:
- lib/jscmd/pipebroker.rb
Instance Attribute Summary collapse
-
#reader ⇒ Object
readonly
Returns the value of attribute reader.
-
#writer ⇒ Object
readonly
Returns the value of attribute writer.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(r, w) ⇒ PipeQueue
constructor
A new instance of PipeQueue.
- #pop ⇒ Object
- #push(obj) ⇒ Object
Constructor Details
#initialize(r, w) ⇒ PipeQueue
Returns a new instance of PipeQueue.
6 7 8 |
# File 'lib/jscmd/pipebroker.rb', line 6 def initialize(r, w) @reader, @writer = [r, w] end |
Instance Attribute Details
#reader ⇒ Object (readonly)
Returns the value of attribute reader.
4 5 6 |
# File 'lib/jscmd/pipebroker.rb', line 4 def reader @reader end |
#writer ⇒ Object (readonly)
Returns the value of attribute writer.
4 5 6 |
# File 'lib/jscmd/pipebroker.rb', line 4 def writer @writer end |
Instance Method Details
#close ⇒ Object
20 21 22 23 |
# File 'lib/jscmd/pipebroker.rb', line 20 def close @reader.close @writer.close end |
#pop ⇒ Object
15 16 17 18 |
# File 'lib/jscmd/pipebroker.rb', line 15 def pop size = @reader.read(4).unpack("N")[0] Marshal.load(@reader.read(size)) end |
#push(obj) ⇒ Object
10 11 12 13 |
# File 'lib/jscmd/pipebroker.rb', line 10 def push(obj) data = Marshal.dump(obj) @writer.write([data.size].pack("N") + data) end |