Class: Robot::Commands::Move

Inherits:
Base
  • Object
show all
Defined in:
lib/robot/commands/move.rb

Constant Summary collapse

MOVE =
'MOVE'

Class Method Summary collapse

Methods inherited from Base

matches

Class Method Details

.call(position) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/robot/commands/move.rb', line 12

def self.call(position)
  {
    Robot::Directions::NORTH => position.north,
    Robot::Directions::SOUTH => position.south,
    Robot::Directions::EAST => position.east,
    Robot::Directions::WEST => position.west
  }.fetch(position.direction)
end

.matches?(command) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/robot/commands/move.rb', line 8

def self.matches?(command)
  command == MOVE
end