Sha256: dd9ce7771fdb784b7a915f30b1706719b751626e004e8deeaf6cf54a654d29a4

Contents?: true

Size: 958 Bytes

Versions: 2

Compression:

Stored size: 958 Bytes

Contents

# frozen_string_literal: true

require "dry-types"

module DjiMqttConnect
  # Types binding for dry-types
  module Types
    include Dry::Types()

    # DJI does not like null, so it returns Integer 0 instead of a Decimal...
    NullInteger = Types::Strict::Integer.constrained(eql: 0)

    # Not a Strict UUID format... turns out DJI doesn't follow one
    UUID = Strict::String.constrained(format: /\A[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\z/i)

    # Just make sure Timestamps are positive
    Timestamp = Types::Integer.constrained(gteq: 0)

    # lat/lng coordinates
    Latitude = NullInteger | Types::JSON::Decimal.constrained(gteq: -90, lteq: 90)
    Longitude = NullInteger | Types::JSON::Decimal.constrained(gteq: -180, lteq: 180)

    # Device Details
    DeviceDomain = Types::Coercible::Integer # dock returns this value as string
    DeviceType = Types::Integer
    DeviceSubType = Types::Integer
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dji_mqtt_connect-0.1.1.4 lib/dji_mqtt_connect/types.rb
dji_mqtt_connect-0.1.1.3 lib/dji_mqtt_connect/types.rb