Sha256: 414914fce7287bbc2823717b9492cb1bf12cf40a859555186d3eba695261a99a
Contents?: true
Size: 521 Bytes
Versions: 2
Compression:
Stored size: 521 Bytes
Contents
# Extend Array with a sort_by_distance method. class Array # This method creates a "distance" attribute on each object, calculates the # distance from the passed origin, and finally sorts the array by the # resulting distance. def sort_by_distance_from(origin, opts={}) warn "[DEPRECATION] `Array#sort_by_distance_from(origin, opts)` is deprecated. Please use Array#sort_by{|e| e.distance_to(origin, opts)} instead which is not destructive" self[0..-1] = sort_by{|e| e.distance_to(origin, opts)} end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
geokit-rails-2.0.0 | lib/geokit-rails/core_extensions.rb |
geokit-rails-2.0.0.rc1 | lib/geokit-rails/core_extensions.rb |