Class: MapKit::DataTypes::MapPoint

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

Overview

Wrapper for MKMapPoint

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ MapPoint

MapPoint.new(50,45) MapPoint.new([50,45]) MapPoint.new(=> 50, :y => 45) MapPoint.new(MKMapPoint)



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/map-kit-wrapper/map_kit_data_types.rb', line 118

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

Instance Attribute Details

#xObject

Returns the value of attribute x.



112
113
114
# File 'lib/map-kit-wrapper/map_kit_data_types.rb', line 112

def x
  @x
end

#yObject

Returns the value of attribute y.



112
113
114
# File 'lib/map-kit-wrapper/map_kit_data_types.rb', line 112

def y
  @y
end

Instance Method Details

#sdkObject



135
136
137
# File 'lib/map-kit-wrapper/map_kit_data_types.rb', line 135

def sdk
  MKMapPointMake(@x, @y)
end

#to_aObject



147
148
149
# File 'lib/map-kit-wrapper/map_kit_data_types.rb', line 147

def to_a
  [@x, @y]
end

#to_hObject



151
152
153
# File 'lib/map-kit-wrapper/map_kit_data_types.rb', line 151

def to_h
  {:x => @x, :y => @y}
end

#to_sObject



155
156
157
# File 'lib/map-kit-wrapper/map_kit_data_types.rb', line 155

def to_s
  to_h.to_s
end