Module: LocoBot::Robot::Direction::West

Defined in:
lib/loco_bot/robot/direction/west.rb

Overview

West direction.

Class Method Summary collapse

Class Method Details

.labelString

Returns the Direction's label.

Returns:

  • (String)

    the Direction's label



20
21
22
# File 'lib/loco_bot/robot/direction/west.rb', line 20

def self.label
  'WEST'
end

.leftDirection::South

Returns the Direction at the left of this one.

Returns:



8
9
10
# File 'lib/loco_bot/robot/direction/west.rb', line 8

def self.left
  Direction::South
end

.rightDirection::North

Returns the Direction at the right of this one.

Returns:



14
15
16
# File 'lib/loco_bot/robot/direction/west.rb', line 14

def self.right
  Direction::North
end

.vector(x, y) ⇒ Hash

The Direction is applied to the given coordinates and returns vectorial coordinates in a Hash.

Examples:

Direction::West.vector(1, 2) # => {x: 0, y: 2}

Parameters:

  • x (Integer)

    the x-axis coordinate

  • y (Integer)

    the y-axis coordinate

Returns:

  • (Hash)

    the vectorial x and y coordinates



30
31
32
# File 'lib/loco_bot/robot/direction/west.rb', line 30

def self.vector(x, y)
  { x: x - 1, y: y }
end