lib/eancom/edifact/segments/pcd.rb in eancom-1.6.3 vs lib/eancom/edifact/segments/pcd.rb in eancom-2.0.0
- old
+ new
@@ -1,44 +1,33 @@
module Eancom
module Edifact
class PCD < Segment
TAG = 'PCD'.freeze
- TYPE = :body.freeze
+ TYPE = :header
attr_reader :segment_type
def initialize(
tag: nil,
- percentage_type_code_qualifier:,
percentage:,
- code_list_identification_code: nil,
- code_list_responsibility_agency_code: nil
+ percentage_type_code_qualifier: nil
)
@tag = tag
@percentage_type_code_qualifier = percentage_type_code_qualifier
@percentage = percentage
- @code_list_identification_code = code_list_identification_code
- @code_list_responsibility_agency_code = code_list_responsibility_agency_code
super(tag: tag || TAG)
end
def to_json_hash
- hash = {
- 'percentage_type_code_qualifier': percentage_type,
- 'percentage': percentage
- }
+ hash = {}
+ hash.merge!(percentage_type_code_qualifier: find_identifier(:percentage_type_code_qualifier)) if @percentage_type_code_qualifier
+ hash.merge!(percentage: @percentage) if @percentage
+ hash
end
def segment_type
TYPE
end
-
- private
-
- def percentage_type
- @percentage_type ||= find_identifier(:percentage_type_code_qualifier)
- end
-
end
end
end