Class: Ndo::Host::Accumulator
- Inherits:
-
Object
- Object
- Ndo::Host::Accumulator
- Defined in:
- lib/ndo/host.rb
Instance Attribute Summary collapse
-
#buffer ⇒ Object
readonly
Returns the value of attribute buffer.
Instance Method Summary collapse
- #copy_if_ready(ready_list) ⇒ Object
- #eof? ⇒ Boolean
-
#initialize(stream) ⇒ Accumulator
constructor
A new instance of Accumulator.
Constructor Details
#initialize(stream) ⇒ Accumulator
Returns a new instance of Accumulator.
28 29 30 31 32 |
# File 'lib/ndo/host.rb', line 28 def initialize(stream) @stream = stream @buffer = '' @eof = false end |
Instance Attribute Details
#buffer ⇒ Object (readonly)
Returns the value of attribute buffer.
26 27 28 |
# File 'lib/ndo/host.rb', line 26 def buffer @buffer end |
Instance Method Details
#copy_if_ready(ready_list) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/ndo/host.rb', line 34 def copy_if_ready(ready_list) return unless ready_list.include?(@stream) @buffer << @stream.read_nonblock(1024) rescue EOFError @eof = true end |
#eof? ⇒ Boolean
42 43 44 |
# File 'lib/ndo/host.rb', line 42 def eof? @eof end |