Class: EventMachine::Synchrony::KeyboardHandler

Inherits:
EM::Connection
  • Object
show all
Includes:
EM::Protocols::LineText2
Defined in:
lib/em-synchrony/keyboard.rb

Instance Method Summary collapse

Constructor Details

#initialize(keyboard) ⇒ KeyboardHandler


17
18
19
# File 'lib/em-synchrony/keyboard.rb', line 17

def initialize(keyboard)
  @keyboard = keyboard
end

Instance Method Details

#receive_line(line) ⇒ Object


21
22
23
24
25
26
# File 'lib/em-synchrony/keyboard.rb', line 21

def receive_line(line)
  # Simulate gets by adding a trailing line feed
  @input = "#{line}#{$/}"
  
  close_connection
end

#unbindObject


28
29
30
# File 'lib/em-synchrony/keyboard.rb', line 28

def unbind
  @keyboard.current_fiber.resume @input
end