Class: Lita::Adapters::Console

Inherits:
Adapter
  • Object
show all
Defined in:
lib/lita/adapters/console.rb

Instance Method Summary collapse

Instance Method Details

#runvoid

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(build_message(robot, input, source))
  end
end

#send_messages(target, strings) ⇒ void

This method returns an undefined value.

Outputs outgoing messages to the shell.

Parameters:

  • target (Lita::Source)

    Unused, since there is only one user in the shell environment.

  • strings (Array<String>)

    An array of strings to output.



27
28
29
# File 'lib/lita/adapters/console.rb', line 27

def send_messages(target, strings)
  puts strings
end

#shut_downvoid

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