Module: ToyRobotController
- Extended by:
- CommandParserHelper
- Defined in:
- lib/toy_robot_controller.rb
Overview
ToyRobotController module which sets up the Robot, Table and execute commands provided
Class Attribute Summary collapse
-
.commands ⇒ Array<Struct>
readonly
return Array of commands if present.
-
.robot ⇒ ToyRobot::Robot
readonly
return [ToyRobot::Robot] if present.
Class Method Summary collapse
-
.init(commands_stream, table_size = 5) ⇒ Object
This method is expecting [Array<String>] of commands such as [‘PLACE 0,0,NORTH’, ‘MOVE’, ‘REPORT’].
Methods included from CommandParserHelper
Methods included from CommandHelper
#a_valid_place_command?, #command_type, #commands, #directions, #split_place_command
Class Attribute Details
.commands ⇒ Array<Struct> (readonly)
return Array of commands if present
example: <struct type=“PLACE”, value=[“0”, “0”, “NORTH”], status=“”, error=“”>
45 46 47 |
# File 'lib/toy_robot_controller.rb', line 45 def commands @commands end |
.robot ⇒ ToyRobot::Robot (readonly)
return [ToyRobot::Robot] if present
39 40 41 |
# File 'lib/toy_robot_controller.rb', line 39 def robot @robot end |
Class Method Details
.init(commands_stream, table_size = 5) ⇒ Object
This method is expecting [Array<String>] of commands such as [‘PLACE 0,0,NORTH’, ‘MOVE’, ‘REPORT’]
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/toy_robot_controller.rb', line 26 def init(commands_stream, table_size = 5) validate_command_stream(commands_stream) @commands_stream = commands_stream @table = Surface::Table.new(table_size, table_size) @robot = ToyRobot::Robot.new(@table) @commands = [] populate_commands execute_commands end |