lib/picky/wrappers/bundle/location.rb in picky-3.4.3 vs lib/picky/wrappers/bundle/location.rb in picky-3.5.0
- old
+ new
@@ -9,35 +9,52 @@
class Location < Calculation
def initialize bundle, options = {}
super bundle
+ user_grid = options[:grid] || raise("Gridsize needs to be given for location #{bundle.identifier}.")
+ anchor = options[:anchor] || 0.0
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
+ @calculation = Calculations::Location.new user_grid, anchor, precision
end
#
#
- def recalculate float
- @calculation.recalculate float
+ def calculate float
+ @calculation.calculate float
end
+ # Recalculates the added location.
#
- #
- def load
- # Load first the bundle, then extract the config.
- #
- bundle.load
- 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
+ def add id, location, where = :unshift
+ @calculation.calculated_range(location.to_s.to_f).each do |new_location|
+ bundle.add id, new_location.to_s, where
+ end
end
# Do not generate a partial.
#
- def generate_partial_from unimportant
- # Nothing.
+ def add_partialized does_not, matter, at_all
+ # Nothing
+ end
+
+ # Save the config, then dump normally.
+ #
+ def dump
+ bundle[:location_anchor] = @calculation.anchor
+
+ bundle.dump
+ end
+
+ # Load first the bundle, then extract the config.
+ #
+ def load
+ bundle.load
+
+ # TODO Symbols (of the location_anchor!!!).
+ #
+ @calculation.anchor = bundle['location_anchor'] && bundle['location_anchor'].to_f || raise("Configuration 'location_anchor' for #{bundle.identifier} missing. Did you run rake index already?")
end
end
end
\ No newline at end of file