Class: Commando::Runner
- Inherits:
-
Object
- Object
- Commando::Runner
- Defined in:
- lib/commando/runner.rb
Instance Method Summary collapse
-
#initialize(config:) ⇒ Runner
constructor
A new instance of Runner.
- #start ⇒ Object
Constructor Details
#initialize(config:) ⇒ Runner
Returns a new instance of Runner.
7 8 9 |
# File 'lib/commando/runner.rb', line 7 def initialize(config:) @config = config end |
Instance Method Details
#start ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/commando/runner.rb', line 11 def start config.output.puts config.greeting io = IOHandler.new(config: config) interpreter = Interpreter.new(config: config) loop do begin if line = io.readline # When the user enters a non-empty string, pass the line to the # interpreter and handle the command. interpreter.interpret(line) end rescue ArgumentError => error config.output.puts "Error: #{error}" rescue QuitException break end end end |