Class: Sunspot::Util::Coordinates

Inherits:
Object
  • Object
show all
Defined in:
lib/sunspot/util.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(coords) ⇒ Coordinates

Returns a new instance of Coordinates.



186
187
188
# File 'lib/sunspot/util.rb', line 186

def initialize(coords)
  @coords = coords
end

Instance Method Details

#latObject



190
191
192
193
194
195
196
197
198
# File 'lib/sunspot/util.rb', line 190

def lat
  if @coords.respond_to?(:first)
    @coords.first
  elsif @coords.respond_to?(:lat)
    @coords.lat
  else
    @coords.latitude
  end.to_f
end

#lngObject



200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'lib/sunspot/util.rb', line 200

def lng
  if @coords.respond_to?(:last)
    @coords.last
  elsif @coords.respond_to?(:lng)
    @coords.lng
  elsif @coords.respond_to?(:lon)
    @coords.lon
  elsif @coords.respond_to?(:long)
    @coords.long
  elsif @coords.respond_to?(:longitude)
    @coords.longitude
  end.to_f
end