Class: CoreLocation::DataTypes::LocationCoordinate
- Inherits:
-
Object
- Object
- CoreLocation::DataTypes::LocationCoordinate
- Defined in:
- lib/map-kit-wrapper/core_location_data_types.rb
Overview
Ruby wrapper for CLLocationCoordinate2D
Instance Attribute Summary collapse
-
#latitude ⇒ Object
Attribute reader.
-
#longitude ⇒ Object
Attribute reader.
Instance Method Summary collapse
-
#api ⇒ Object
Returns the wrapped iOS CLLocationCoordinate2D object.
-
#initialize(*args) ⇒ LocationCoordinate
constructor
Initializer for LocationCoordinate.
-
#to_a ⇒ Object
Get self as an Array.
-
#to_h ⇒ Object
Get self as a Hash.
-
#to_s ⇒ Object
Get self as a String.
Constructor Details
#initialize(*args) ⇒ LocationCoordinate
Initializer for LocationCoordinate
-
Args :
The initializer takes a variety of arguments
LocationCoordinate.new(1,2)
LocationCoordinate.new([1,2])
LocationCoordinate.new({:latitude => 1, :longitude => 2})
LocationCoordinate.new(LocationCoordinate)
LocationCoordinate.new(CLLocationCoordinate2D)
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/map-kit-wrapper/core_location_data_types.rb', line 32 def initialize(*args) args.flatten! self.latitude, self.longitude = case args.size when 1 arg = args.first if arg.is_a? Hash [arg[:latitude], arg[:longitude]] else # For LocationCoordinate, CLLocationCoordinate2D [arg.latitude, arg.longitude] end when 2 [args[0], args[1]] end end |
Instance Attribute Details
#latitude ⇒ Object
Attribute reader
18 19 20 |
# File 'lib/map-kit-wrapper/core_location_data_types.rb', line 18 def latitude @latitude end |
#longitude ⇒ Object
Attribute reader
18 19 20 |
# File 'lib/map-kit-wrapper/core_location_data_types.rb', line 18 def longitude @longitude end |
Instance Method Details
#api ⇒ Object
Returns the wrapped iOS CLLocationCoordinate2D object
51 52 53 |
# File 'lib/map-kit-wrapper/core_location_data_types.rb', line 51 def api CLLocationCoordinate2DMake(@latitude, @longitude) end |
#to_a ⇒ Object
Get self as an Array
-
Returns :
-
[latitude, longitude]
-
81 82 83 |
# File 'lib/map-kit-wrapper/core_location_data_types.rb', line 81 def to_a [@latitude, @longitude] end |
#to_h ⇒ Object
Get self as a Hash
-
Returns :
-
{:latitude => latitude, :longitude => longitude}
-
91 92 93 |
# File 'lib/map-kit-wrapper/core_location_data_types.rb', line 91 def to_h {:latitude => @latitude, :longitude => @longitude} end |
#to_s ⇒ Object
Get self as a String
-
Returns :
-
"{:latitude => latitude, :longitude => longitude}"
-
101 102 103 |
# File 'lib/map-kit-wrapper/core_location_data_types.rb', line 101 def to_s to_h.to_s end |