Sha256: 477dd8b45f2f8c5a62f10a46b284970973d091579fd6ebe897653c028a43985a

Contents?: true

Size: 488 Bytes

Versions: 4

Compression:

Stored size: 488 Bytes

Contents

# frozen_string_literal: true

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

      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

4 entries across 4 versions & 1 rubygems

Version Path
robot_rea-0.1.9 lib/robot/commands/move.rb
robot_rea-0.1.8 lib/robot/commands/move.rb
robot_rea-0.1.7 lib/robot/commands/move.rb
robot_rea-0.1.6 lib/robot/commands/move.rb