Sha256: 108128f449078af5b17778fe8cdcbab314d0252fb8b52fea5e54d05d93b29728

Contents?: true

Size: 851 Bytes

Versions: 1

Compression:

Stored size: 851 Bytes

Contents

module CoreLocation
  # Wrappers for the Core Location Data Types
  # http://developer.apple.com/library/mac/#documentation/CoreLocation/Reference/CoreLocationDataTypesRef/Reference/reference.html
  module DataTypes

    # Ruby wrapper for CLLocationCoordinate2D
    class LocationCoordinate
      attr_reader :sdk

      # LocationCoordinate.new(1,2)
      # LocationCoordinate.new([1,2])
      # CoordinateSpan.new(CLLocationCoordinate2D)
      def initialize(*args)
        args.flatten!
        if args.first.is_a?(CLLocationCoordinate2D)
          @sdk = args.first
        else
          @sdk = CLLocationCoordinate2DMake(args[0], args[1])
        end
      end

      def latitude
        @sdk.latitude
      end

      def longitude
        @sdk.longitude
      end

      def to_array
        [latitude, longitude]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
map-kit-wrapper-0.0.1 motion/core_location_data_types.rb