Module: Qbot::Adapter::Shell::Keyboard

Includes:
EM::Protocols::LineText2
Defined in:
lib/qbot/adapter/shell.rb

Instance Method Summary collapse

Instance Method Details

#initialize(callback) ⇒ Object



13
14
15
16
# File 'lib/qbot/adapter/shell.rb', line 13

def initialize(callback)
  @callback = callback
  $stdout.print ">> "
end

#receive_line(text) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/qbot/adapter/shell.rb', line 18

def receive_line(text)
  exit 0 if text.strip == 'exit'

  message = Qbot::Message.new
  message.data = text
  message.text = text

  @callback.call(message)
  $stdout.print ">> "
end