Class: DistanceCollection

Inherits:
Array
  • Object
show all
Defined in:
lib/geokit-rails/core_extensions.rb

Instance Method Summary collapse

Instance Method Details

#set_distance_from(origin, opts = {}) ⇒ Object



2
3
4
5
6
7
# File 'lib/geokit-rails/core_extensions.rb', line 2

def set_distance_from(origin, opts={})
  distance_attribute_name = opts.delete(:distance_attribute_name) || 'distance'
  klass = first.class
  klass.send(:attr_accessor, distance_attribute_name) if !klass.respond_to?("#{distance_attribute_name}=")
  each{|e| e.send("#{distance_attribute_name}=", e.distance_to(origin,opts)) }
end