Class: MapKit::DataTypes::CoordinateSpan
- Inherits:
-
Object
- Object
- MapKit::DataTypes::CoordinateSpan
- Defined in:
- lib/map-kit-wrapper/map_kit_data_types.rb
Overview
Wrapper for MKCoordinateSpan
Instance Attribute Summary collapse
-
#latitude_delta ⇒ Object
Attribute reader.
-
#longitude_delta ⇒ Object
Attribute reader.
Instance Method Summary collapse
-
#api ⇒ Object
Returns the wrapped iOS MKCoordinateSpan object.
-
#initialize(*args) ⇒ CoordinateSpan
constructor
Initializer for CoordinateSpan.
-
#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) ⇒ CoordinateSpan
Initializer for CoordinateSpan
-
Args :
The initializer takes a variety of arguments
CoordinateSpan.new(1,2)
CoordinateSpan.new([1,2])
CoordinateSpan.new({:latitude_delta => 1, :longitude_delta => 2})
CoordinateSpan.new(CoordinateSpan)
CoordinateSpan.new(MKCoordinateSpan)
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/map-kit-wrapper/map_kit_data_types.rb', line 33 def initialize(*args) args.flatten! self.latitude_delta, self.longitude_delta = case args.size when 1 arg = args.first case arg when MKCoordinateSpan [arg.latitudeDelta, arg.longitudeDelta] when CoordinateSpan [arg.latitude_delta, arg.longitude_delta] when Hash [arg[:latitude_delta], arg[:longitude_delta]] end when 2 [args[0], args[1]] end end |
Instance Attribute Details
#latitude_delta ⇒ Object
Attribute reader
20 21 22 |
# File 'lib/map-kit-wrapper/map_kit_data_types.rb', line 20 def latitude_delta @latitude_delta end |
#longitude_delta ⇒ Object
Attribute reader
20 21 22 |
# File 'lib/map-kit-wrapper/map_kit_data_types.rb', line 20 def longitude_delta @longitude_delta end |
Instance Method Details
#api ⇒ Object
Returns the wrapped iOS MKCoordinateSpan object
-
Returns :
-
A MKCoordinateSpan representation of self
-
58 59 60 |
# File 'lib/map-kit-wrapper/map_kit_data_types.rb', line 58 def api MKCoordinateSpanMake(@latitude_delta, @longitude_delta) end |
#to_a ⇒ Object
Get self as an Array
-
Returns :
-
[latitude_delta, longitude_delta]
-
88 89 90 |
# File 'lib/map-kit-wrapper/map_kit_data_types.rb', line 88 def to_a [@latitude_delta, @longitude_delta] end |
#to_h ⇒ Object
Get self as a Hash
-
Returns :
-
{:latitude_delta => latitude_delta, :longitude_delta => longitude_delta}
-
98 99 100 |
# File 'lib/map-kit-wrapper/map_kit_data_types.rb', line 98 def to_h {:latitude_delta => @latitude_delta, :longitude_delta => @longitude_delta} end |
#to_s ⇒ Object
Get self as a String
-
Returns :
-
"{:latitude_delta => latitude_delta, :longitude_delta => longitude_delta}"
-
108 109 110 |
# File 'lib/map-kit-wrapper/map_kit_data_types.rb', line 108 def to_s to_h.to_s end |