lib/picky/sources/wrappers/location.rb in picky-2.7.0 vs lib/picky/sources/wrappers/location.rb in picky-3.0.0.pre1

- old
+ new

@@ -1,49 +1,53 @@ -module Sources +module Picky - module Wrappers + module Sources - # Should this actually just be a tokenizer? - # - class Location < Base + module Wrappers - attr_reader :calculation + # Should this actually just be a tokenizer? + # + class Location < Base - def initialize source, grid, precision = 1 - super source - @calculation = Calculations::Location.new grid, precision - end + attr_reader :calculation - # Yield the data (id, text for id) for the given category. - # - def harvest category - minimum = 1.0/0 + def initialize source, grid, precision = 1 + super source + @calculation = Calculations::Location.new grid, precision + end - # Cache. TODO Make option? + # Yield the data (id, text for id) for the given category. # - locations = [] + def harvest category + minimum = 1.0/0 - # Gather min/max. - # - source.harvest category do |indexed_id, location| - location = location.to_f - minimum = location if location < minimum - locations << [indexed_id, location] - end + # Cache. + # + locations = [] - calculation.minimum = minimum + # Gather min/max. + # + source.harvest category do |indexed_id, location| + location = location.to_f + minimum = location if location < minimum + locations << [indexed_id, location] + end - # Recalculate locations. - # - locations.each do |indexed_id, location| - calculation.recalculated_range(location).each do |new_location| - yield indexed_id, new_location.to_s + calculation.minimum = minimum + + # Recalculate locations. + # + locations.each do |indexed_id, location| + calculation.recalculated_range(location).each do |new_location| + yield indexed_id, new_location.to_s + end end + + # TODO Move to the right place. + # + category.indexing_exact[:location_minimum] = minimum end - # TODO Move to the right place. - # - category.indexing_exact[:location_minimum] = minimum end end end \ No newline at end of file