Class: Hardstatus::Controller
- Inherits:
-
EventMachine::Protocols::LineAndTextProtocol
- Object
- EventMachine::Protocols::LineAndTextProtocol
- Hardstatus::Controller
- Defined in:
- lib/hardstatus/controller.rb
Instance Method Summary collapse
-
#initialize(hardstatus) ⇒ Controller
constructor
A new instance of Controller.
- #receive_line(line) ⇒ Object
- #send_line(line) ⇒ Object
Constructor Details
#initialize(hardstatus) ⇒ Controller
Returns a new instance of Controller.
14 15 16 17 18 |
# File 'lib/hardstatus/controller.rb', line 14 def initialize (hardstatus) super @hardstatus = hardstatus end |
Instance Method Details
#receive_line(line) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/hardstatus/controller.rb', line 20 def receive_line (line) send_line begin @hardstatus.render(line.strip.to_sym) rescue Exception => e e.inspect end close_connection_after_writing end |
#send_line(line) ⇒ Object
30 31 32 33 34 |
# File 'lib/hardstatus/controller.rb', line 30 def send_line (line) raise ArgumentError, 'the line already has a newline character' if line.include? "\n" send_data line.dup.force_encoding('BINARY') << "\r\n" end |