Class: GoogleMapsAPI::Core::Coordinate
- Inherits:
-
Object
- Object
- GoogleMapsAPI::Core::Coordinate
- Defined in:
- lib/google_maps_api/core/coordinate.rb
Instance Attribute Summary collapse
-
#lat ⇒ Object
readonly
Returns the value of attribute lat.
-
#lng ⇒ Object
readonly
Returns the value of attribute lng.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(lat, lng) ⇒ Coordinate
constructor
A new instance of Coordinate.
- #latitude ⇒ Object
- #lon ⇒ Object
- #longitude ⇒ Object
- #to_a ⇒ Object
- #to_ary ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(lat, lng) ⇒ Coordinate
Returns a new instance of Coordinate.
4 5 6 7 |
# File 'lib/google_maps_api/core/coordinate.rb', line 4 def initialize(lat, lng) @lat = lat.to_f @lng = lng.to_f end |
Instance Attribute Details
#lat ⇒ Object (readonly)
Returns the value of attribute lat.
2 3 4 |
# File 'lib/google_maps_api/core/coordinate.rb', line 2 def lat @lat end |
#lng ⇒ Object (readonly)
Returns the value of attribute lng.
2 3 4 |
# File 'lib/google_maps_api/core/coordinate.rb', line 2 def lng @lng end |
Class Method Details
.from_array(array) ⇒ Object
37 38 39 |
# File 'lib/google_maps_api/core/coordinate.rb', line 37 def self.from_array(array) self.new(array[0], array[1]) end |
.from_hash(hash) ⇒ Object
33 34 35 |
# File 'lib/google_maps_api/core/coordinate.rb', line 33 def self.from_hash(hash) self.new(hash["lat"], hash["lng"]) end |
Instance Method Details
#latitude ⇒ Object
9 10 11 |
# File 'lib/google_maps_api/core/coordinate.rb', line 9 def latitude lat end |
#lon ⇒ Object
17 18 19 |
# File 'lib/google_maps_api/core/coordinate.rb', line 17 def lon lng end |
#longitude ⇒ Object
13 14 15 |
# File 'lib/google_maps_api/core/coordinate.rb', line 13 def longitude lng end |
#to_a ⇒ Object
21 22 23 |
# File 'lib/google_maps_api/core/coordinate.rb', line 21 def to_a [lat, lng] end |
#to_ary ⇒ Object
25 26 27 |
# File 'lib/google_maps_api/core/coordinate.rb', line 25 def to_ary to_a end |
#to_h ⇒ Object
29 30 31 |
# File 'lib/google_maps_api/core/coordinate.rb', line 29 def to_h {"lat" => lat, "lng" => lng} end |