Class: Lita::Adapters::Console
- Inherits:
-
Adapter
- Object
- Adapter
- Lita::Adapters::Console
- Defined in:
- lib/lita/adapters/console.rb
Instance Method Summary collapse
-
#run ⇒ void
Creates a “Shell User” and then loops a prompt and input, passing the incoming messages to the robot.
-
#send_messages(target, strings) ⇒ void
Outputs outgoing messages to the shell.
-
#shut_down ⇒ void
Adds a blank line for a nice looking exit.
Instance Method Details
#run ⇒ void
This method returns an undefined value.
Creates a “Shell User” and then loops a prompt and input, passing the incoming messages to the robot.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/lita/adapters/console.rb', line 10 def run user = User.create(1, name: "Shell User") source = Source.new(user: user) puts 'Type "exit" or "quit" to end the session.' while line = Readline.readline("#{robot.name} > ", true) input = line.chomp.strip break if input == "exit" || input == "quit" robot.receive((robot, input, source)) end end |
#send_messages(target, strings) ⇒ void
This method returns an undefined value.
Outputs outgoing messages to the shell.
27 28 29 |
# File 'lib/lita/adapters/console.rb', line 27 def (target, strings) puts strings end |
#shut_down ⇒ void
This method returns an undefined value.
Adds a blank line for a nice looking exit.
33 34 35 |
# File 'lib/lita/adapters/console.rb', line 33 def shut_down puts end |