Class: MapKit::DataTypes::MapRect

Inherits:
Object
  • Object
show all
Defined in:
lib/map-kit-wrapper/map_kit_data_types.rb

Overview

Wrapper for MKMapRect

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ MapRect

MapRect.new(x, y, width, height) MapRect.new([x, y], [width, height]) MapRect.new(=> {:x => 5.0, :y => 8.0, :size => => 6.0, :height => 9.0}) MapRect.new(MapPoint, MapSize) MapRect.new(MKMapPoint, MKMapSize) MapRect.new(MapRect) MapRect.new(MKMapRect)



222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
# File 'lib/map-kit-wrapper/map_kit_data_types.rb', line 222

def initialize(*args)
  self.origin, self.size =
      case args.size
        when 1
          arg = args[0]
          case arg
            when Hash
              [arg[:origin], arg[:size]]
            else
              [arg.origin, arg.size]
          end
        when 2
          [args[0], args[1]]
        when 4
          [[args[0], args[1]], [args[2], args[3]]]
      end
end

Instance Attribute Details

#originObject

Returns the value of attribute origin.



213
214
215
# File 'lib/map-kit-wrapper/map_kit_data_types.rb', line 213

def origin
  @origin
end

#sizeObject

Returns the value of attribute size.



213
214
215
# File 'lib/map-kit-wrapper/map_kit_data_types.rb', line 213

def size
  @size
end

Instance Method Details

#sdkObject



240
241
242
# File 'lib/map-kit-wrapper/map_kit_data_types.rb', line 240

def sdk
  MKMapRectMake(@origin.x, @origin.y, @size.width, @size.height)
end

#to_hObject



252
253
254
# File 'lib/map-kit-wrapper/map_kit_data_types.rb', line 252

def to_h
  {:origin => @origin.to_h, :size => @size.to_h}
end

#to_sObject



256
257
258
# File 'lib/map-kit-wrapper/map_kit_data_types.rb', line 256

def to_s
  to_h.to_s
end