Class: MapKit::DataTypes::CoordinateRegion
- Inherits:
-
Object
- Object
- MapKit::DataTypes::CoordinateRegion
- Includes:
- CoreLocation::DataTypes
- Defined in:
- lib/map-kit-wrapper/map_kit_data_types.rb
Overview
Wrapper for MKCoordinateRegion
Instance Attribute Summary collapse
-
#center ⇒ Object
Attribute reader.
-
#span ⇒ Object
Attribute reader.
Instance Method Summary collapse
-
#api ⇒ Object
Returns the wrapped iOS MKCoordinateRegion object.
-
#initialize(*args) ⇒ CoordinateRegion
constructor
Initializer for CoordinateRegion.
-
#to_h ⇒ Object
Get self as a Hash.
-
#to_s ⇒ Object
Get self as a String.
Constructor Details
#initialize(*args) ⇒ CoordinateRegion
Initializer for CoordinateRegion
-
Args :
The initializer takes a variety of arguments
CoordinateRegion.new(CoordinateRegion)
CoordinateRegion.new(MKCoordinateRegion)
CoordinateRegion.new([56, 10.6], [3.1, 3.1])
CoordinateRegion.new({:center => {:latitude => 56, :longitude => 10.6},
:span => {:latitude_delta => 3.1, :longitude_delta => 3.1}}
CoordinateRegion.new(LocationCoordinate, CoordinateSpan)
CoordinateRegion.new(CLLocationCoordinate2D, MKCoordinateSpan)
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/map-kit-wrapper/map_kit_data_types.rb', line 137 def initialize(*args) self.center, self.span = case args.size when 1 arg = args[0] case arg when Hash [arg[:center], arg[:span]] else [arg.center, arg.span] end when 2 [args[0], args[1]] end end |
Instance Attribute Details
#center ⇒ Object
Attribute reader
121 122 123 |
# File 'lib/map-kit-wrapper/map_kit_data_types.rb', line 121 def center @center end |
#span ⇒ Object
Attribute reader
121 122 123 |
# File 'lib/map-kit-wrapper/map_kit_data_types.rb', line 121 def span @span end |
Instance Method Details
#api ⇒ Object
Returns the wrapped iOS MKCoordinateRegion object
-
Returns :
-
A MKCoordinateRegion representation of self
-
159 160 161 |
# File 'lib/map-kit-wrapper/map_kit_data_types.rb', line 159 def api MKCoordinateRegionMake(@center.api, @span.api) end |
#to_h ⇒ Object
Get self as a Hash
-
Returns :
-
{:center => {:latitude => latitude, :longitude => longitude}, :span => {:latitude_delta => latitude_delta, :longitude_delta => longitude_delta}}
-
189 190 191 |
# File 'lib/map-kit-wrapper/map_kit_data_types.rb', line 189 def to_h {:center => @center.to_h, :span => @span.to_h} end |
#to_s ⇒ Object
Get self as a String
-
Returns :
-
"{:center => {:latitude => latitude, :longitude => longitude}, :span => {:latitude_delta => latitude_delta, :longitude_delta => longitude_delta}}"
-
199 200 201 |
# File 'lib/map-kit-wrapper/map_kit_data_types.rb', line 199 def to_s to_h.to_s end |