Class: Socrates::Bots::CLIBot

Inherits:
Object
  • Object
show all
Defined in:
lib/socrates/bots/cli_bot.rb

Instance Method Summary collapse

Constructor Details

#initialize(state_factory:) ⇒ CLIBot

Returns a new instance of CLIBot.



4
5
6
7
# File 'lib/socrates/bots/cli_bot.rb', line 4

def initialize(state_factory:)
  @adapter    = ConsoleAdapter.new
  @dispatcher = Core::Dispatcher.new(adapter: @adapter, state_factory: state_factory)
end

Instance Method Details

#startObject



9
10
11
12
13
14
15
16
# File 'lib/socrates/bots/cli_bot.rb', line 9

def start
  # Clear out any remnants from previous runs.
  @storage.clear(ConsoleAdapter::CLIENT_ID)

  while (input = gets.chomp)
    @dispatcher.dispatch(message: input)
  end
end