Class: Eancom::Edifact::PAT

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

Constant Summary collapse

TAG =
'PAT'.freeze
TYPE =
:header

Instance Attribute Summary collapse

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_message?, #structure, #tag?, #to_edi, #to_hash, #to_s, #validate_structure

Constructor Details

#initialize(tag: nil, payment_terms_type_code_qualifier: nil, payment_terms_type_description_identifier: nil, time_reference_code: nil) ⇒ PAT

Returns a new instance of PAT.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/eancom/edifact/segments/pat.rb', line 9

def initialize(
  tag: nil,
  payment_terms_type_code_qualifier: nil,
  payment_terms_type_description_identifier: nil,
  time_reference_code: nil
)

  @tag = tag,
  @payment_terms_type_code_qualifier = payment_terms_type_code_qualifier,
  @payment_terms_type_description_identifier = payment_terms_type_description_identifier,
  @time_reference_code = time_reference_code

  super(tag: tag || TAG)
end

Instance Attribute Details

#segment_typeObject (readonly)

Returns the value of attribute segment_type.



7
8
9
# File 'lib/eancom/edifact/segments/pat.rb', line 7

def segment_type
  @segment_type
end

Instance Method Details

#to_json_hashObject



24
25
26
27
28
29
30
# File 'lib/eancom/edifact/segments/pat.rb', line 24

def to_json_hash
  hash = {}
  hash.merge!(payment_terms_type_code_qualifier: find_identifier(:payment_terms_type_code_qualifier)) if @payment_terms_type_code_qualifier
  hash.merge!(payment_terms_type_description_identifier: @payment_terms_type_description_identifier) if @payment_terms_type_description_identifier
  hash.merge!(time_reference_code: @time_reference_code) if @time_reference_code
  hash
end