Module: LocoBot::Robot::Direction::South

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

Overview

South 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/south.rb', line 20

def self.label
  'SOUTH'
end

.leftDirection::East

Returns the Direction at the left of this one.

Returns:



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

def self.left
  Direction::East
end

.rightDirection::West

Returns the Direction at the right of this one.

Returns:



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

def self.right
  Direction::West
end

.vector(x, y) ⇒ Hash

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

Examples:

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

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/south.rb', line 30

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