Module: LocoBot::Robot::Direction::North

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

Overview

North 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/north.rb', line 20

def self.label
  'NORTH'
end

.leftDirection::West

Returns the Direction at the left of this one.

Returns:



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

def self.left
  Direction::West
end

.rightDirection::East

Returns the Direction at the right of this one.

Returns:



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

def self.right
  Direction::East
end

.vector(x, y) ⇒ Hash

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

Examples:

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

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

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