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