Class: PushBot::Location

Inherits:
Object
  • Object
show all
Defined in:
lib/push_bot/location.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lat, lng) ⇒ Location

Returns a new instance of Location.



5
6
7
8
# File 'lib/push_bot/location.rb', line 5

def initialize(lat, lng)
  @lat = lat
  @lng = lng
end

Instance Attribute Details

#latObject (readonly)

Returns the value of attribute lat.



3
4
5
# File 'lib/push_bot/location.rb', line 3

def lat
  @lat
end

#lngObject (readonly)

Returns the value of attribute lng.



3
4
5
# File 'lib/push_bot/location.rb', line 3

def lng
  @lng
end

Class Method Details

.parse(*location) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/push_bot/location.rb', line 10

def self.parse(*location)
  location.flatten!

  return location if location.size == 2
  location = location.first

  return [location.lat, location.lng] if location.respond_to?(:lat) && location.respond_to?(:lng)
  return [location.lat, location.lon] if location.respond_to?(:lat) && location.respond_to?(:lon)

  [location.latitude, location.longitude] if location.respond_to?(:latitude) && location.respond_to?(:longitude)
end