Class: EventMachine::HandlerSocket::Deferrable

Inherits:
EM::DefaultDeferrable
  • Object
show all
Defined in:
lib/em-handlersocket/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#bufferObject

Returns the value of attribute buffer.



5
6
7
# File 'lib/em-handlersocket/client.rb', line 5

def buffer
  @buffer
end

#linesObject

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

Returns:

  • (Boolean)


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

#succeedObject



28
29
30
# File 'lib/em-handlersocket/client.rb', line 28

def succeed
  super(@buffer)
end