Sha256: b2a9ee4713bb646c9125f88ee81cc5fc53588c281c789396923e9618d53f6cf8

Contents?: true

Size: 827 Bytes

Versions: 15

Compression:

Stored size: 827 Bytes

Contents

module Eancom
  module Edifact
    class QTY < Segment
      TAG = 'QTY'.freeze
      TYPE = :body.freeze

      def initialize(
        tag: nil,
        quantity_type_code_qualifier:,
        quantity:,
        measurement_unit_code: nil
      )
        @tag = tag
        @quantity_type_code_qualifier = quantity_type_code_qualifier
        @quantity = quantity
        @measurement_unit_code = measurement_unit_code

        super(tag: tag || TAG)
      end

      def to_json_hash
        {
          identifier => {
              quantity: @quantity
            }
        }
      end

      def segment_type
        TYPE
      end

      private

      def identifier
        @identifier ||= structure.find(:quantity_type_code_qualifier).dictionary[@quantity_type_code_qualifier][:identifier]
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
eancom-1.6.3 lib/eancom/edifact/segments/qty.rb
eancom-1.6.2 lib/eancom/edifact/segments/qty.rb
eancom-1.6.0 lib/eancom/edifact/segments/qty.rb
eancom-1.5.7 lib/eancom/edifact/segments/qty.rb
eancom-1.5.6 lib/eancom/edifact/segments/qty.rb
eancom-1.5.5 lib/eancom/edifact/segments/qty.rb
eancom-1.5.4 lib/eancom/edifact/segments/qty.rb
eancom-1.5.2 lib/eancom/edifact/segments/qty.rb
eancom-1.5.1 lib/eancom/edifact/segments/qty.rb
eancom-1.5.0 lib/eancom/edifact/segments/qty.rb
eancom-1.4.0 lib/eancom/edifact/segments/qty.rb
eancom-1.3.0 lib/eancom/edifact/segments/qty.rb
eancom-1.2.0 lib/eancom/edifact/segments/qty.rb
eancom-1.1.1 lib/eancom/edifact/segments/qty.rb
eancom-1.1.0 lib/eancom/edifact/segments/qty.rb