Class: Socrates::Bots::CLI

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

Instance Method Summary collapse

Constructor Details

#initialize(state_factory:, adapter: nil) ⇒ CLI

Returns a new instance of CLI.



7
8
9
10
# File 'lib/socrates/bots/cli.rb', line 7

def initialize(state_factory:, adapter: nil)
  @adapter    = adapter || Adapters::Console.new
  @dispatcher = Core::Dispatcher.new(adapter: @adapter, state_factory: state_factory)
end

Instance Method Details

#startObject



12
13
14
15
16
17
18
# File 'lib/socrates/bots/cli.rb', line 12

def start
  context = { channel: "CONSOLE" }

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