Class: Ndo::Host::Accumulator

Inherits:
Object
  • Object
show all
Defined in:
lib/ndo/host.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#bufferObject (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

Returns:

  • (Boolean)


42
43
44
# File 'lib/ndo/host.rb', line 42

def eof?
  @eof
end