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.



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

def initialize(coords)
  @coords = coords
end

Instance Method Details

#latObject



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

def lat
  if @coords.respond_to?(:[])
    @coords[0]
  else
    @coords.lat
  end.to_f
end

#lngObject



197
198
199
200
201
202
203
204
205
206
207
# File 'lib/sunspot/util.rb', line 197

def lng
  if @coords.respond_to?(:[])
    @coords[1]
  elsif @coords.respond_to?(:lng)
    @coords.lng
  elsif @coords.respond_to?(:lon)
    @coords.lon
  elsif @coords.respond_to?(:long)
    @coords.long
  end.to_f
end