Class: MarsRover::Direction

Inherits:
Object
  • Object
show all
Defined in:
lib/mars_rover/direction.rb

Class Method Summary collapse

Class Method Details

.turn_left(rover) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/mars_rover/direction.rb', line 16

def self.turn_left(rover)
  case rover.direction
  when 'N'
    rover.direction = 'W'
  when 'W'
    rover.direction = 'S'
  when 'S'
    rover.direction = 'E'
  when 'E'
    rover.direction = 'N'
  end
end

.turn_right(rover) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/mars_rover/direction.rb', line 3

def self.turn_right(rover)
  case rover.direction
  when 'N'
    rover.direction = 'E'
  when 'E'
    rover.direction = 'S'
  when 'S'
    rover.direction = 'W'
  when 'W'
    rover.direction = 'N'
  end
end