Class: Eancom::Edifact::FTX

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

Constant Summary collapse

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

Instance Attribute Summary collapse

Attributes inherited from Segment

#tag

Instance Method Summary collapse

Methods inherited from Segment

#array, 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, text_subject_code_qualifier:, free_text_function_code: nil, free_text_value_code: nil, code_list_identification_code: nil, code_list_responsible_agency_code: nil, free_text_value_1: nil, free_text_value_2: nil, free_text_value_3: nil, free_text_value_4: nil, free_text_value_5: nil) ⇒ FTX

Returns a new instance of FTX.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/eancom/edifact/segments/ftx.rb', line 9

def initialize(
  tag: nil,
  text_subject_code_qualifier:,
  free_text_function_code: nil,
  free_text_value_code: nil,
  code_list_identification_code: nil,
  code_list_responsible_agency_code: nil,
  free_text_value_1: nil,
  free_text_value_2: nil,
  free_text_value_3: nil,
  free_text_value_4: nil,
  free_text_value_5: nil
)
  @tag = tag
  @text_subject_code_qualifier = text_subject_code_qualifier
  @free_text_function_code = free_text_function_code
  @free_text_value_code = free_text_value_code
  @code_list_identification_code = code_list_identification_code
  @code_list_responsible_agency_code = code_list_responsible_agency_code
  @free_text_value_1 = free_text_value_1
  @free_text_value_2 = free_text_value_2
  @free_text_value_3 = free_text_value_3
  @free_text_value_4 = free_text_value_4
  @free_text_value_5 = free_text_value_5

  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/ftx.rb', line 7

def segment_type
  @segment_type
end

Instance Method Details

#group_nameObject



56
57
58
# File 'lib/eancom/edifact/segments/ftx.rb', line 56

def group_name
  'free_texts'
end

#to_json_hashObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/eancom/edifact/segments/ftx.rb', line 37

def to_json_hash
  hash = {}
  hash.merge!(text_subject_code_qualifier: @text_subject_code_qualifier) if @text_subject_code_qualifier
  hash.merge!(free_text_function_code: find_identifier(:free_text_function_code)) if @free_text_function_code
  hash.merge!(free_text_value_code: @free_text_value_code) if @free_text_value_code
  hash.merge!(code_list_identification_code: @code_list_identification_code) if @code_list_identification_code
  hash.merge!(code_list_responsible_agency_code: find_identifier(:code_list_responsible_agency_code)) if @code_list_responsible_agency_code
  hash.merge!(free_text_value_1: @free_text_value_1) if @free_text_value_1
  hash.merge!(free_text_value_2: @free_text_value_2) if @free_text_value_2
  hash.merge!(free_text_value_3: @free_text_value_3) if @free_text_value_3
  hash.merge!(free_text_value_4: @free_text_value_4) if @free_text_value_4
  hash.merge!(free_text_value_5: @free_text_value_5) if @free_text_value_4
  hash
end