Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/geo_calc/extensions/array.rb
Instance Method Summary collapse
-
#to_lat ⇒ Object
Assumes by default that the order is lat, lng If GeoPoint is defined, can reverse this order depending on #coord_mode class variable.
- #to_lat_lng ⇒ Object
-
#to_lng ⇒ Object
see(#to_lat).
- #to_lng_lat ⇒ Object
- #trim ⇒ Object
Instance Method Details
#to_lat ⇒ Object
Assumes by default that the order is lat, lng If GeoPoint is defined, can reverse this order depending on #coord_mode class variable
13 14 15 16 17 18 19 20 |
# File 'lib/geo_calc/extensions/array.rb', line 13 def to_lat raise "Array must contain at least one element to return the latitude" if empty? if defined?(GeoPoint) && GeoPoint.respond_to?(:coord_mode) && GeoPoint.coord_mode == :lng_lat self[1].to_lat else first.to_lat end end |
#to_lat_lng ⇒ Object
2 3 4 5 |
# File 'lib/geo_calc/extensions/array.rb', line 2 def to_lat_lng raise "Array must contain at least two elements to be converted to latitude and longitude" if !(size >= 2) [to_lat, to_lng] end |
#to_lng ⇒ Object
see(#to_lat)
23 24 25 26 27 28 29 30 |
# File 'lib/geo_calc/extensions/array.rb', line 23 def to_lng raise "Array must contain at least two elements to return the longitude" if !self[1] if defined?(GeoPoint) && GeoPoint.respond_to?(:coord_mode) && GeoPoint.coord_mode == :lng_lat first.to_lng else self[1].to_lng end end |
#to_lng_lat ⇒ Object
7 8 9 |
# File 'lib/geo_calc/extensions/array.rb', line 7 def to_lng_lat to_lat_lng.reverse end |
#trim ⇒ Object
32 33 34 |
# File 'lib/geo_calc/extensions/array.rb', line 32 def trim join.trim end |