Sha256: 2be661f64ba6b3ee6a97ef219bbd688fb6864245438653d00d921108581dd55a

Contents?: true

Size: 1.2 KB

Versions: 22

Compression:

Stored size: 1.2 KB

Contents

module Picky

  module Sources

    module Wrappers

      # Should this actually just be a tokenizer?
      #
      class Location < Base

        attr_reader :calculation

        def initialize source, grid, precision = 1
          super source
          @calculation = Calculations::Location.new grid, precision
        end

        # Yield the data (id, text for id) for the given category.
        #
        def harvest category
          minimum = 1.0/0

          # Cache.
          #
          locations = []

          # Gather min/max.
          #
          source.harvest category do |indexed_id, location|
            location = location.to_f
            minimum = location if location < minimum
            locations << [indexed_id, location]
          end

          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

      end

    end

  end

end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
picky-3.0.0.pre2 lib/picky/sources/wrappers/location.rb
picky-3.0.0.pre1 lib/picky/sources/wrappers/location.rb