Class: Command

Inherits:
Object
  • Object
show all
Defined in:
lib/another_toy_robot/command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#paramsObject

Returns the value of attribute params.



2
3
4
# File 'lib/another_toy_robot/command.rb', line 2

def params
  @params
end

#targetObject

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

#executeObject



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_initializeObject



11
# File 'lib/another_toy_robot/command.rb', line 11

def post_initialize; end

#valid?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/another_toy_robot/command.rb', line 18

def valid?
  true
end