Sha256: 721547af60bd6bf8ce2ab8a5f5460f806c43106f3730045a3726cc1250b520ec

Contents?: true

Size: 788 Bytes

Versions: 4

Compression:

Stored size: 788 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)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dji_mqtt_connect-0.1.1.2 lib/dji_mqtt_connect/types.rb
dji_mqtt_connect-0.1.1.1 lib/dji_mqtt_connect/types.rb
dji_mqtt_connect-0.1.1 lib/dji_mqtt_connect/types.rb
dji_mqtt_connect-0.1.0 lib/dji_mqtt_connect/types.rb