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.



165
166
167
# File 'lib/sunspot/util.rb', line 165

def initialize(coords)
  @coords = coords
end

Instance Method Details

#latObject



169
170
171
172
173
174
175
# File 'lib/sunspot/util.rb', line 169

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

#lngObject



177
178
179
180
181
182
183
184
185
186
187
# File 'lib/sunspot/util.rb', line 177

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