Class: Command
- Inherits:
-
Object
- Object
- Command
- Defined in:
- lib/another_toy_robot/command.rb
Direct Known Subclasses
InvalidCommand, LeftCommand, MoveCommand, PlaceCommand, ReportCommand, RightCommand
Instance Attribute Summary collapse
-
#params ⇒ Object
Returns the value of attribute params.
-
#target ⇒ Object
Returns the value of attribute target.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(target: nil, params: nil) ⇒ Command
constructor
A new instance of Command.
- #post_initialize ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(target: nil, params: nil) ⇒ Command
Returns a new instance of Command.
4 5 6 7 8 9 |
# File 'lib/another_toy_robot/command.rb', line 4 def initialize(target: nil, params: nil) @target = target @params = params post_initialize end |
Instance Attribute Details
#params ⇒ Object
Returns the value of attribute params.
2 3 4 |
# File 'lib/another_toy_robot/command.rb', line 2 def params @params end |
#target ⇒ Object
Returns the value of attribute target.
2 3 4 |
# File 'lib/another_toy_robot/command.rb', line 2 def target @target end |
Instance Method Details
#execute ⇒ Object
13 14 15 16 |
# File 'lib/another_toy_robot/command.rb', line 13 def execute return InvalidCommand.new.execute unless valid? issue_command end |
#post_initialize ⇒ Object
11 |
# File 'lib/another_toy_robot/command.rb', line 11 def post_initialize; end |
#valid? ⇒ Boolean
18 19 20 |
# File 'lib/another_toy_robot/command.rb', line 18 def valid? true end |