Class: MapKit::DataTypes::MapSize

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

Overview

Wrapper for MKMapSize

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ MapSize

Initializer for MapSize

  • Args :

The initializer takes a variety of arguments

MapSize.new(10,12)
MapSize.new([10,12])
MapSize.new({:width => 10, :height => 12})
MapSize.new(MKMapSize)
MapSize.new(MapSize)


322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
# File 'lib/map-kit-wrapper/map_kit_data_types.rb', line 322

def initialize(*args)
  args.flatten!
  self.width, self.height =
      case args.size
        when 1
          arg = args[0]
          case arg
            when Hash
              [arg[:width], arg[:height]]
            else
              [arg.width, arg.height]
          end
        when 2
          [args[0], args[1]]
      end
end

Instance Attribute Details

#heightObject

Attribute reader



308
309
310
# File 'lib/map-kit-wrapper/map_kit_data_types.rb', line 308

def height
  @height
end

#widthObject

Attribute reader



308
309
310
# File 'lib/map-kit-wrapper/map_kit_data_types.rb', line 308

def width
  @width
end

Instance Method Details

#apiObject

Returns the wrapped iOS MKMapSize object

  • Returns :

    • A MKMapSize representation of self



345
346
347
# File 'lib/map-kit-wrapper/map_kit_data_types.rb', line 345

def api
  MKMapSizeMake(@width, @height)
end

#to_aObject

Get self as an Array

  • Returns :

    • [@width, @height]



375
376
377
# File 'lib/map-kit-wrapper/map_kit_data_types.rb', line 375

def to_a
  [@width, @height]
end

#to_hObject

Get self as a Hash

  • Returns :

    • {:width => width, :height => height}



385
386
387
# File 'lib/map-kit-wrapper/map_kit_data_types.rb', line 385

def to_h
  {:width => @width, :height => @height}
end

#to_sObject

Get self as a String

  • Returns :

    • "{:width => width, :height => height}"



395
396
397
# File 'lib/map-kit-wrapper/map_kit_data_types.rb', line 395

def to_s
  to_h.to_s
end