Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/geo_calc/extensions/array.rb

Instance Method Summary collapse

Instance Method Details

#to_latObject

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_lngObject



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_lngObject

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_latObject



7
8
9
# File 'lib/geo_calc/extensions/array.rb', line 7

def to_lng_lat
  to_lat_lng.reverse
end

#trimObject



32
33
34
# File 'lib/geo_calc/extensions/array.rb', line 32

def trim
  join.trim
end