Sha256: 24b1fa65169703f885e061ac08534877df124462a55e53bb2c4df43d83e28a8b

Contents?: true

Size: 467 Bytes

Versions: 2

Compression:

Stored size: 467 Bytes

Contents

module Robot
  module Commands
    class Move < Base
      MOVE = 'MOVE'.freeze

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

      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
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
robot_rea-0.1.5 lib/robot/commands/move.rb
robot_rea-0.1.4 lib/robot/commands/move.rb