Class: Eancom::Edifact::QTY

Inherits:
Segment
  • Object
show all
Defined in:
lib/eancom/edifact/segments/qty.rb

Constant Summary collapse

TAG =
'QTY'.freeze
TYPE =
:body.freeze

Instance Attribute Summary

Attributes inherited from Segment

#tag

Instance Method Summary collapse

Methods inherited from Segment

#array, #group_name, initialize_by_components, #is_body?, #is_footer?, #is_header?, #item_group_name, #starts_item?, #starts_location?, #starts_message?, #structure, #tag?, #to_edi, #to_hash, #to_s, #validate_structure

Constructor Details

#initialize(tag: nil, quantity_type_code_qualifier:, quantity:, measurement_unit_code: nil) ⇒ QTY

Returns a new instance of QTY.



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/eancom/edifact/segments/qty.rb', line 7

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

Instance Method Details

#segment_typeObject



29
30
31
# File 'lib/eancom/edifact/segments/qty.rb', line 29

def segment_type
  TYPE
end

#to_json_hashObject



21
22
23
24
25
26
27
# File 'lib/eancom/edifact/segments/qty.rb', line 21

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