Sha256: dafe7ece342f3057b0811503f081e185f35354cbbed19e0672e85c0343018a8c

Contents?: true

Size: 1.07 KB

Versions: 15

Compression:

Stored size: 1.07 KB

Contents

module Picky

  module Tokenizers

    class Location < Picky::Tokenizer # TODO Still needed?

      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

      #
      #
      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

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
picky-3.2.0 lib/picky/tokenizers/location.rb
picky-3.1.13 lib/picky/tokenizers/location.rb
picky-3.1.12 lib/picky/tokenizers/location.rb
picky-3.1.11 lib/picky/tokenizers/location.rb
picky-3.1.10 lib/picky/tokenizers/location.rb
picky-3.1.9 lib/picky/tokenizers/location.rb
picky-3.1.8 lib/picky/tokenizers/location.rb
picky-3.1.7 lib/picky/tokenizers/location.rb
picky-3.1.6 lib/picky/tokenizers/location.rb
picky-3.1.5 lib/picky/tokenizers/location.rb
picky-3.1.4 lib/picky/tokenizers/location.rb
picky-3.1.3 lib/picky/tokenizers/location.rb
picky-3.1.2 lib/picky/tokenizers/location.rb
picky-3.1.1 lib/picky/tokenizers/location.rb
picky-3.1.0 lib/picky/tokenizers/location.rb