Sha256: 4b4b7e6b0d05aa23a50d4ec83c4a7e3f43d038133216deed8cb23cee28dbe63e

Contents?: true

Size: 947 Bytes

Versions: 23

Compression:

Stored size: 947 Bytes

Contents

# frozen_string_literal: true

module DjiMqttConnect
  module Mixins
    # Provides checks for the output object that contains a Types::ServicesOutputStatus status value
    module ServicesOutputStatusChecks
      # Provide accessors for each status value
      DjiMqttConnect::Types::ServicesOutputStatus.values.each do |status_value|
        define_method(:"status_#{status_value}?") { status == status_value }
      end

      def status_finalized?
        [
          Types::SERVICE_OUTPUT_STATUS_OK,
          Types::SERVICE_OUTPUT_STATUS_REJECTED,
          Types::SERVICE_OUTPUT_STATUS_FAILED,
          Types::SERVICE_OUTPUT_STATUS_CANCELED,
          Types::SERVICE_OUTPUT_STATUS_TIMEOUT
        ].include?(status)
      end
      alias_method :status_finalised?, :status_finalized?

      def humanized_status
        I18n.t(status, scope: "dji_mqtt_connect.services_output_status", default: status.titleize)
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
dji_mqtt_connect-0.1.25.1 lib/dji_mqtt_connect/mixins/services_output_status_checks.rb
dji_mqtt_connect-0.1.25 lib/dji_mqtt_connect/mixins/services_output_status_checks.rb
dji_mqtt_connect-0.1.24.1 lib/dji_mqtt_connect/mixins/services_output_status_checks.rb
dji_mqtt_connect-0.1.24 lib/dji_mqtt_connect/mixins/services_output_status_checks.rb
dji_mqtt_connect-0.1.23.3 lib/dji_mqtt_connect/mixins/services_output_status_checks.rb
dji_mqtt_connect-0.1.23.2 lib/dji_mqtt_connect/mixins/services_output_status_checks.rb
dji_mqtt_connect-0.1.23.1 lib/dji_mqtt_connect/mixins/services_output_status_checks.rb
dji_mqtt_connect-0.1.23 lib/dji_mqtt_connect/mixins/services_output_status_checks.rb
dji_mqtt_connect-0.1.22.2 lib/dji_mqtt_connect/mixins/services_output_status_checks.rb
dji_mqtt_connect-0.1.22.1 lib/dji_mqtt_connect/mixins/services_output_status_checks.rb
dji_mqtt_connect-0.1.22 lib/dji_mqtt_connect/mixins/services_output_status_checks.rb
dji_mqtt_connect-0.1.21 lib/dji_mqtt_connect/mixins/services_output_status_checks.rb
dji_mqtt_connect-0.1.20.1 lib/dji_mqtt_connect/mixins/services_output_status_checks.rb
dji_mqtt_connect-0.1.20 lib/dji_mqtt_connect/mixins/services_output_status_checks.rb
dji_mqtt_connect-0.1.19.2 lib/dji_mqtt_connect/mixins/services_output_status_checks.rb
dji_mqtt_connect-0.1.19.1 lib/dji_mqtt_connect/mixins/services_output_status_checks.rb
dji_mqtt_connect-0.1.19 lib/dji_mqtt_connect/mixins/services_output_status_checks.rb
dji_mqtt_connect-0.1.18 lib/dji_mqtt_connect/mixins/services_output_status_checks.rb
dji_mqtt_connect-0.1.17.1 lib/dji_mqtt_connect/mixins/services_output_status_checks.rb
dji_mqtt_connect-0.1.17 lib/dji_mqtt_connect/mixins/services_output_status_checks.rb