Sha256: fd2766758d25f550329fbd7d523c62b610faa20f43bb930b8534f3926e818cbe

Contents?: true

Size: 839 Bytes

Versions: 37

Compression:

Stored size: 839 Bytes

Contents

class Gillbus
  class Tariff
    class ReturnCause
      LOSSLESS = 'lossless'.freeze

      extend Fields
      include UpdateAttrs

      field :lossless, :bool

      field :cause, :string

      # rubocop:disable Lint/UnusedMethodArgument
      def self.parse(doc, instance: nil, parent: nil, options: {})
        instance = new
        if doc.is_a?(Array) && doc.size == 2 && doc.first.is_a?(Hash) && doc.last.is_a?(String)
          instance.lossless = doc.first[LOSSLESS] == Parser::TRUE_CONST
          instance.cause = doc.last
        elsif doc.is_a?(Hash) && doc.has_key?('__content__')
          instance.lossless = (doc['lossless'] == 'true')
          instance.cause = doc['__content__']
        else
          instance.cause = doc
          instance.lossless = false
        end
        instance
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
gillbus-0.23.0 lib/gillbus/structs/tariff/return_cause.rb
gillbus-0.22.9 lib/gillbus/structs/tariff/return_cause.rb
gillbus-0.22.8 lib/gillbus/structs/tariff/return_cause.rb
gillbus-0.22.7 lib/gillbus/structs/tariff/return_cause.rb
gillbus-0.22.6 lib/gillbus/structs/tariff/return_cause.rb
gillbus-0.22.5 lib/gillbus/structs/tariff/return_cause.rb
gillbus-0.22.4 lib/gillbus/structs/tariff/return_cause.rb
gillbus-0.22.3 lib/gillbus/structs/tariff/return_cause.rb
gillbus-0.22.2 lib/gillbus/structs/tariff/return_cause.rb
gillbus-0.22.1 lib/gillbus/structs/tariff/return_cause.rb
gillbus-0.22.0 lib/gillbus/structs/tariff/return_cause.rb
gillbus-0.21.0 lib/gillbus/structs/tariff/return_cause.rb
gillbus-0.20.9 lib/gillbus/structs/tariff/return_cause.rb
gillbus-0.20.8 lib/gillbus/structs/tariff/return_cause.rb
gillbus-0.20.7 lib/gillbus/structs/tariff/return_cause.rb
gillbus-0.20.6 lib/gillbus/structs/tariff/return_cause.rb
gillbus-0.20.5 lib/gillbus/structs/tariff/return_cause.rb
gillbus-0.20.4 lib/gillbus/structs/tariff/return_cause.rb
gillbus-0.20.3 lib/gillbus/structs/tariff/return_cause.rb
gillbus-0.20.2 lib/gillbus/structs/tariff/return_cause.rb