Module: LocoBot::Robot::Direction::East

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

Overview

East 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/east.rb', line 20

def self.label
  'EAST'
end

.leftDirection::North

Returns the Direction at the left of this one.

Returns:



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

def self.left
  Direction::North
end

.rightDirection::South

Returns the Direction at the right of this one.

Returns:



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

def self.right
  Direction::South
end

.vector(x, y) ⇒ Hash

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

Examples:

Direction::East.vector(1, 2) # => {x: 2, 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/east.rb', line 30

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