Sha256: 517b8267e6fbcc9f82acd945cc3bd253d78957cc7e9394bd959b9f4264fe5ade

Contents?: true

Size: 993 Bytes

Versions: 1

Compression:

Stored size: 993 Bytes

Contents

module Tokenizers

  class Location < Base

    attr_reader :calculation

    def initialize options = {}
      super options

      grid      = options[:grid]
      precision = options[:precision] || 1

      @calculation = Calculations::Location.new grid, precision

      @minimum = 1.0 / 0

      @locations = []
    end

    # TODO Work on this!
    #
    def tokenize text

      # 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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
picky-2.6.0 lib/picky/tokenizers/location.rb