Class: EventMachine::HandlerSocket::Deferrable
- Inherits:
-
EM::DefaultDeferrable
- Object
- EM::DefaultDeferrable
- EventMachine::HandlerSocket::Deferrable
- Defined in:
- lib/em-handlersocket/client.rb
Instance Attribute Summary collapse
-
#buffer ⇒ Object
Returns the value of attribute buffer.
-
#lines ⇒ Object
Returns the value of attribute lines.
Instance Method Summary collapse
-
#done? ⇒ Boolean
non zero response code, or we’ve processed all lines.
-
#initialize(lines) ⇒ Deferrable
constructor
A new instance of Deferrable.
- #recieve(line) ⇒ Object
- #succeed ⇒ Object
Constructor Details
#initialize(lines) ⇒ Deferrable
Returns a new instance of Deferrable.
7 8 9 10 |
# File 'lib/em-handlersocket/client.rb', line 7 def initialize(lines) @lines = lines @buffer = [] end |
Instance Attribute Details
#buffer ⇒ Object
Returns the value of attribute buffer.
5 6 7 |
# File 'lib/em-handlersocket/client.rb', line 5 def buffer @buffer end |
#lines ⇒ Object
Returns the value of attribute lines.
5 6 7 |
# File 'lib/em-handlersocket/client.rb', line 5 def lines @lines end |
Instance Method Details
#done? ⇒ Boolean
non zero response code, or we’ve processed all lines
26 |
# File 'lib/em-handlersocket/client.rb', line 26 def done?; (@buffer.size == @lines); end |
#recieve(line) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/em-handlersocket/client.rb', line 12 def recieve(line) status, cols, data = line.chomp.split("\t") @buffer.push data # non-zero response code indicates error if status.to_i != 0 fail return true end done? end |
#succeed ⇒ Object
28 29 30 |
# File 'lib/em-handlersocket/client.rb', line 28 def succeed super(@buffer) end |