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 21 22 |
# 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? subject, other = (defined?(GeoPoint) && GeoPoint.respond_to?(:coord_mode) && GeoPoint.coord_mode == :lng_lat) ? [self[1], first] : [first, self[1]] begin subject.to_lat rescue GeoDirectionMisMatch other.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)
25 26 27 28 29 30 31 32 33 |
# File 'lib/geo_calc/extensions/array.rb', line 25 def to_lng raise "Array must contain at least two elements to return the longitude" if !self[1] subject, other = (defined?(GeoPoint) && GeoPoint.respond_to?(:coord_mode) && GeoPoint.coord_mode == :lng_lat) ? [first, self[1]] : [self[1], first] begin subject.to_lng rescue GeoDirectionMisMatch other.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_lng, to_lat] end |
#trim ⇒ Object
35 36 37 |
# File 'lib/geo_calc/extensions/array.rb', line 35 def trim join.trim end |