Sha256: b419a10c604a335ebae0f1bda21b2e7dddfe2f00f4f7947de509d5ed97eb3578

Contents?: true

Size: 1.12 KB

Versions: 8

Compression:

Stored size: 1.12 KB

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

    InvalidTemperature = Types::Integer.constrained(gteq: 1300) # maximum temp of k-type thermocouple, errors are usually 30K+
    Temperature = InvalidTemperature | Types::JSON::Decimal
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
dji_mqtt_connect-0.1.8 lib/dji_mqtt_connect/types.rb
dji_mqtt_connect-0.1.7 lib/dji_mqtt_connect/types.rb
dji_mqtt_connect-0.1.6 lib/dji_mqtt_connect/types.rb
dji_mqtt_connect-0.1.5 lib/dji_mqtt_connect/types.rb
dji_mqtt_connect-0.1.4.1 lib/dji_mqtt_connect/types.rb
dji_mqtt_connect-0.1.4 lib/dji_mqtt_connect/types.rb
dji_mqtt_connect-0.1.3 lib/dji_mqtt_connect/types.rb
dji_mqtt_connect-0.1.2 lib/dji_mqtt_connect/types.rb