Class: Kanal::Interfaces::SimpleCli::SimpleCliInterface
- Inherits:
-
Core::Interfaces::Interface
- Object
- Core::Interfaces::Interface
- Kanal::Interfaces::SimpleCli::SimpleCliInterface
- Defined in:
- lib/kanal/interfaces/simple_cli/simple_cli_interface.rb
Overview
This interface provides input/output with the cli
Instance Attribute Summary
Attributes inherited from Core::Interfaces::Interface
Instance Method Summary collapse
-
#initialize(core) ⇒ SimpleCliInterface
constructor
<Description>.
- #start ⇒ Object
- #stop ⇒ Object
Methods inherited from Core::Interfaces::Interface
#consume_input, #consume_output, #modify_core, #router
Constructor Details
#initialize(core) ⇒ SimpleCliInterface
<Description>
16 17 18 19 20 21 22 23 |
# File 'lib/kanal/interfaces/simple_cli/simple_cli_interface.rb', line 16 def initialize(core) super # For simple cli we need body @core.register_plugin Kanal::Plugins::Batteries::BatteriesPlugin.new @core.register_output_parameter :quit end |
Instance Method Details
#start ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/kanal/interfaces/simple_cli/simple_cli_interface.rb', line 25 def start loop do puts ">>>" input = @core.create_input input.body = gets output = router.create_output_for_input input if output.quit puts "Undestood! Quitting" break end puts "[bot]: #{output.body}" rescue Interrupt puts "Got it! Hard stop. Bye bye!" break end puts "End of conversation!" end |
#stop ⇒ Object
47 |
# File 'lib/kanal/interfaces/simple_cli/simple_cli_interface.rb', line 47 def stop; end |