Class: ToyRobot::Application
- Inherits:
-
Object
- Object
- ToyRobot::Application
- Defined in:
- lib/toy_robot/application.rb
Instance Method Summary collapse
-
#initialize(argv = [], args = {}) ⇒ Application
constructor
A new instance of Application.
- #run(options = nil) ⇒ Object
Constructor Details
#initialize(argv = [], args = {}) ⇒ Application
Returns a new instance of Application.
6 7 8 9 10 |
# File 'lib/toy_robot/application.rb', line 6 def initialize(argv = [], args = {}) @input = args[:input] || $stdin @parser = Command::Parser @controller = Factory.create(:controller) end |
Instance Method Details
#run(options = nil) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/toy_robot/application.rb', line 12 def run( = nil) loop do raw_input = input.gets break unless raw_input raw_input.chomp! command = parser.parse(raw_input) controller.send(command.msg, command.args) if command end end |