Sha256: 180464e84e5d535e528c991d025bc19fa71ca0b9d80d16a98aaa83211a445f3a

Contents?: true

Size: 1.06 KB

Versions: 10

Compression:

Stored size: 1.06 KB

Contents

module Internals

  module Tokenizers


    class Location < Base

      attr_reader :calculation

      def initialize options = {}
        super options

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

        @calculation = Internals::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.exact[:location_minimum] = minimum
      end

    end

  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
picky-2.5.2 lib/picky/internals/tokenizers/location.rb
picky-2.5.1 lib/picky/internals/tokenizers/location.rb
picky-2.5.0 lib/picky/internals/tokenizers/location.rb
picky-2.4.3 lib/picky/internals/tokenizers/location.rb
picky-2.4.2 lib/picky/internals/tokenizers/location.rb
picky-2.4.1 lib/picky/internals/tokenizers/location.rb
picky-2.4.0 lib/picky/internals/tokenizers/location.rb
picky-2.3.0 lib/picky/internals/tokenizers/location.rb
picky-2.2.1 lib/picky/internals/tokenizers/location.rb
picky-2.2.0 lib/picky/internals/tokenizers/location.rb