Skip to content

Commit ae1d935

Browse files
refactor: replaced method with a constant.
1 parent 6ff3796 commit ae1d935

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

lib/planar_map.rb

+8-10
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def self.forwards(location, direction = location.direction)
1616
end
1717

1818
def self.backwards(location, direction = location.direction)
19-
forwards(location, invert(direction))
19+
forwards(location, INVERT[direction])
2020
end
2121

2222

@@ -45,13 +45,11 @@ def self.rotate_right(location)
4545
)
4646
end
4747

48-
def self.invert(direction)
49-
{
50-
'N' => 'S',
51-
'S' => 'N',
52-
'E' => 'W',
53-
'W' => 'E'
54-
}[direction]
55-
end
56-
private_class_method :invert
48+
INVERT = {
49+
'N' => 'S',
50+
'S' => 'N',
51+
'E' => 'W',
52+
'W' => 'E'
53+
}
54+
private_constant :INVERT
5755
end

0 commit comments

Comments
 (0)