lib/picky/calculations/location.rb in picky-0.12.3 vs lib/picky/calculations/location.rb in picky-1.0.0
- old
+ new
@@ -1,6 +1,6 @@
-module Calculations
+module Calculations # :nodoc:all
# A location calculation recalculates a 1-d location
# to the Picky internal 1-d "grid".
#
# For example, if you have a location x == 12.3456,
@@ -16,10 +16,18 @@
@precision = precision || 1
@grid = @user_grid / (@precision + 0.5)
end
def minimum= minimum
+ # Add a margin of 1 user grid.
+ #
minimum -= @user_grid
+
+ # Add plus 1 grid so that the index key never falls on 0.
+ # Why? to_i maps by default to 0.
+ #
+ minimum -= @grid
+
@minimum = minimum
end
#
#
\ No newline at end of file