Sha256: 14594cf326f4b8fe842d477b17c2107bb9daf1ce7edb27fb5acc466e6dce4293

Contents?: true

Size: 1.13 KB

Versions: 17

Compression:

Stored size: 1.13 KB

Contents

module Picky

  module Indexed
    module Wrappers

      module Bundle

        # A location calculation recalculates a location to the Picky internal location.
        #
        class Location < Calculation

          def initialize bundle, options = {}
            super bundle

            precision  = options[:precision] || 1
            user_grid  = options[:grid] || raise("Gridsize needs to be given for location #{bundle.identifier}.")

            @calculation = Calculations::Location.new user_grid, precision
          end

          #
          #
          def recalculate float
            @calculation.recalculate float
          end

          #
          #
          def load
            # Load first the bundle, then extract the config.
            #
            bundle.load
            # THINK Can I move the to_f to the backend?
            #
            minimum = bundle[:location_minimum] && bundle[:location_minimum].to_f || raise("Configuration :location_minimum for #{bundle.identifier} missing. Did you run rake index already?")
            @calculation.minimum = minimum
          end

        end

      end

    end
  end

end

Version data entries

17 entries across 17 versions & 1 rubygems

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