Skip to content

Commit cc26f48

Browse files
committed
Fix rubocop errors
1 parent 2bee6e0 commit cc26f48

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

ruby/lib/plus_codes/open_location_code.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def full?(code)
4444
# @return [Array<Integer, Integer>] with the latitude and longitude integer
4545
# values.
4646
def location_to_integers(latitude, longitude)
47+
lat_val = (latitude * PAIR_CODE_PRECISION * LAT_GRID_PRECISION).floor
4748
lat_val = (latitude * PAIR_CODE_PRECISION * LAT_GRID_PRECISION).floor
4849
lat_val += 90 * PAIR_CODE_PRECISION * LAT_GRID_PRECISION
4950
if lat_val.negative?
@@ -52,6 +53,7 @@ def location_to_integers(latitude, longitude)
5253
lat_val = 2 * 90 * PAIR_CODE_PRECISION * LAT_GRID_PRECISION - 1
5354
end
5455
lng_val = (longitude * PAIR_CODE_PRECISION * LNG_GRID_PRECISION).floor
56+
lng_val = (longitude * PAIR_CODE_PRECISION * LNG_GRID_PRECISION).floor
5557
lng_val += 180 * PAIR_CODE_PRECISION * LNG_GRID_PRECISION
5658
if lng_val.negative?
5759
# Ruby's % operator differs from other languages in that it returns

ruby/test/plus_codes_test.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ def test_decode
4242
end
4343

4444
def test_encode
45-
# Allow a 5% error rate encoding from degree coordinates (because of floating point precision).
46-
allowedErrorRate = 0.05
45+
# Allow a 5% error rate encoding from degree coordinates (because of
46+
# floating point precision).
47+
allowed_error_rate = 0.05
4748
errors = 0
4849
tests = 0
4950
read_csv_lines('encoding.csv').each do |line|
@@ -62,7 +63,7 @@ def test_encode
6263
puts "ENCODING DIFFERENCE: want #{want}, got #{code}"
6364
end
6465
end
65-
assert_compare(errors.to_f / tests.to_f, "<=", allowedErrorRate)
66+
assert_compare(errors.to_f / tests, '<=', allowed_error_rate)
6667
end
6768

6869
def test_location_to_integers
@@ -76,7 +77,8 @@ def test_location_to_integers
7677
lng_integer = cols[3].to_i
7778

7879
got_lat, got_lng = @olc.location_to_integers(lat_degrees, lng_degrees)
79-
# Due to floating point precision limitations, we may get values 1 less than expected.
80+
# Due to floating point precision limitations, we may get values 1 less
81+
# than expected.
8082
assert_include([lat_integer - 1, lat_integer], got_lat)
8183
assert_include([lng_integer - 1, lng_integer], got_lng)
8284
end

0 commit comments

Comments
 (0)