Class: ToyRobot::Bin::Runner

Inherits:
Object
  • Object
show all
Includes:
IOUtils
Defined in:
lib/toy_robot/bin/runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from IOUtils

#_print, #delay, #green, #print_with_delay, #red, #yellow

Constructor Details

#initializeRunner

Returns a new instance of Runner.



9
10
11
12
13
# File 'lib/toy_robot/bin/runner.rb', line 9

def initialize
  @simulator   = ToyRobot::Simulator.new
  @roboto      = @simulator.roboto
  @roboto.name = robots.sample
end

Instance Attribute Details

#robotoObject (readonly)

Returns the value of attribute roboto.



7
8
9
# File 'lib/toy_robot/bin/runner.rb', line 7

def roboto
  @roboto
end

#selected_optionObject (readonly)

Returns the value of attribute selected_option.



7
8
9
# File 'lib/toy_robot/bin/runner.rb', line 7

def selected_option
  @selected_option
end

#simulatorObject (readonly)

Returns the value of attribute simulator.



7
8
9
# File 'lib/toy_robot/bin/runner.rb', line 7

def simulator
  @simulator
end

Instance Method Details

#startObject



15
16
17
18
19
20
21
# File 'lib/toy_robot/bin/runner.rb', line 15

def start
  show_art
  show_help
  show_options
  @selected_option = capture_input
  handle_selected_option
end