Class: Messed::EMRunner::StatusHandler

Inherits:
EventMachine::Connection
  • Object
show all
Defined in:
lib/messed/em_runner.rb

Constant Summary collapse

Terminator =
"\r\n"
TerminatorRegex =
/\r\n/
Error =
"ERROR\r\n"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#interfaceObject

Returns the value of attribute interface.



8
9
10
# File 'lib/messed/em_runner.rb', line 8

def interface
  @interface
end

Instance Method Details

#receive_data(data) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/messed/em_runner.rb', line 14

def receive_data(data)
  ss = StringScanner.new(data)
  while part = ss.scan_until(TerminatorRegex)
    if part == 'status'
      send_data(interface.status)
      send_data(Terminator)
    else
      send_data(Error)
    end
  end
end