Sha256: 4bb5f278c3e9ce2381cf255f003619a1735766593f7d6b169073bf55948085ad

Contents?: true

Size: 1.11 KB

Versions: 14

Compression:

Stored size: 1.11 KB

Contents

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

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
picky-2.1.2 lib/picky/internals/indexed/wrappers/bundle/location.rb
picky-2.1.1 lib/picky/internals/indexed/wrappers/bundle/location.rb
picky-2.1.0 lib/picky/internals/indexed/wrappers/bundle/location.rb
picky-2.0.0 lib/picky/internals/indexed/wrappers/bundle/location.rb
picky-2.0.0.pre3 lib/picky/internals/indexed/wrappers/bundle/location.rb
picky-2.0.0.pre2 lib/picky/internals/indexed/wrappers/bundle/location.rb
picky-2.0.0.pre1 lib/picky/internals/indexed/wrappers/bundle/location.rb
picky-1.5.4 lib/picky/internals/indexed/wrappers/bundle/location.rb
picky-1.5.3 lib/picky/internals/indexed/wrappers/bundle/location.rb
picky-1.5.2 lib/picky/internals/indexed/wrappers/bundle/location.rb
picky-1.5.1 lib/picky/internals/indexed/wrappers/bundle/location.rb
picky-1.5.0 lib/picky/internals/indexed/wrappers/bundle/location.rb
picky-1.4.3 lib/picky/internals/indexed/wrappers/bundle/location.rb
picky-1.4.2 lib/picky/internals/indexed/wrappers/bundle/location.rb