Class: Robot::CommandCentre::Command
- Inherits:
-
Object
- Object
- Robot::CommandCentre::Command
- Defined in:
- lib/robot/command_centre.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#robot ⇒ Object
readonly
Returns the value of attribute robot.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(command_string) ⇒ Command
constructor
A new instance of Command.
- #place? ⇒ Boolean
- #validate ⇒ Object
Constructor Details
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
24 25 26 |
# File 'lib/robot/command_centre.rb', line 24 def args @args end |
#command ⇒ Object (readonly)
Returns the value of attribute command.
24 25 26 |
# File 'lib/robot/command_centre.rb', line 24 def command @command end |
#robot ⇒ Object (readonly)
Returns the value of attribute robot.
24 25 26 |
# File 'lib/robot/command_centre.rb', line 24 def robot @robot end |
Instance Method Details
#execute ⇒ Object
31 32 33 34 35 |
# File 'lib/robot/command_centre.rb', line 31 def execute return robot.place(args) if place? return robot.send(:"#{command.downcase}") if robot.table.placed? CommandCentre.instance.say('Does not compute, You must place me first') end |
#place? ⇒ Boolean
37 38 39 |
# File 'lib/robot/command_centre.rb', line 37 def place? command == 'PLACE' end |
#validate ⇒ Object
41 42 43 |
# File 'lib/robot/command_centre.rb', line 41 def validate COMMANDS.include?(command) end |