Skip to content

Commit

Permalink
Refactor: Inline Variable.
Browse files Browse the repository at this point in the history
  • Loading branch information
hemalvarambhia committed Oct 31, 2023
1 parent 05d8df4 commit 7fa77c3
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@ def initialize(x_domain:, y_domain:, obstacles: [])
def next_location_forwards(location:)
case location.direction
when 'N'
new_location = location.forwards
corrected_for_north_pole(new_location)
corrected_for_north_pole(location.forwards)
when 'E'
next_x = at_right_hand_edge?(location.coordinates) ? @x_domain.begin : location.coordinates.x + 1
Location.new(
coordinates: Coordinates.new(x: next_x, y: location.coordinates.y),
direction: location.direction
)
when 'S'
new_location = location.forwards
corrected_for_south_pole(new_location)
corrected_for_south_pole(location.forwards)
when 'W'
next_x = at_left_hand_edge?(location.coordinates) ? @x_domain.end : location.coordinates.x - 1
Location.new(
Expand Down

0 comments on commit 7fa77c3

Please sign in to comment.