Class: Eancom::Edifact::ALI

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

Constant Summary collapse

TAG =
'ALI'.freeze
TYPE =
:body

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, country_of_origin_name_code: nil, duty_regime_type_code: nil, special_condition_code_1: nil, special_condition_code_2: nil, special_condition_code_3: nil, special_condition_code_4: nil, special_condition_code_5: nil) ⇒ ALI

Returns a new instance of ALI.



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

def initialize(
  tag: nil,
  country_of_origin_name_code: nil,
  duty_regime_type_code: nil,
  special_condition_code_1: nil,
  special_condition_code_2: nil,
  special_condition_code_3: nil,
  special_condition_code_4: nil,
  special_condition_code_5: nil
)
  @tag = tag
  @country_of_origin_name_code = country_of_origin_name_code
  @duty_regime_type_code = duty_regime_type_code
  @special_condition_code_1 = special_condition_code_1
  @special_condition_code_2 = special_condition_code_2
  @special_condition_code_3 = special_condition_code_3
  @special_condition_code_4 = special_condition_code_4
  @special_condition_code_5 = special_condition_code_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/ali.rb', line 7

def segment_type
  @segment_type
end

Instance Method Details

#to_json_hashObject



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/eancom/edifact/segments/ali.rb', line 31

def to_json_hash
  hash = {}
  hash.merge!(country_of_origin_name_code: @country_of_origin_name_code) if @country_of_origin_name_code
  hash.merge!(duty_regime_type_code: @duty_regime_type_code) if @duty_regime_type_code
  hash.merge!(special_condition_code_1: find_identifier(:special_condition_code_1)) if @special_condition_code_1
  hash.merge!(special_condition_code_2: find_identifier(:special_condition_code_2)) if @special_condition_code_2
  hash.merge!(special_condition_code_3: find_identifier(:special_condition_code_3)) if @special_condition_code_3
  hash.merge!(special_condition_code_4: find_identifier(:special_condition_code_4)) if @special_condition_code_4
  hash.merge!(special_condition_code_5: find_identifier(:special_condition_code_5)) if @special_condition_code_5
  outer_hash = {}
  outer_hash.merge!(additional_information: hash)
  outer_hash
end