Class: Eancom::Edifact::LIN

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

Constant Summary collapse

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

Instance Attribute Summary

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

Constructor Details

#initialize(tag: nil, line_item_identifier_1:, action_request_notification_description_code: '', item_identifier:, item_type_identification_code:, sub_line_indicator_code: nil, line_item_identifier_2: nil) ⇒ LIN

Returns a new instance of LIN.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/eancom/edifact/segments/lin.rb', line 7

def initialize(
  tag: nil,
  line_item_identifier_1:,
  action_request_notification_description_code: '',
  item_identifier:,
  item_type_identification_code:,
  sub_line_indicator_code: nil,
  line_item_identifier_2: nil
)
  @tag = tag
  @line_item_identifier_1 = line_item_identifier_1
  @action_request_notification_description_code = action_request_notification_description_code
  @item_identifier = item_identifier
  @item_type_identification_code = item_type_identification_code
  @sub_line_indicator_code = sub_line_indicator_code
  @line_item_identifier_2 = line_item_identifier_2

  super(tag: tag || TAG )
end

Instance Method Details

#segment_typeObject



41
42
43
# File 'lib/eancom/edifact/segments/lin.rb', line 41

def segment_type
  TYPE
end

#starts_item?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/eancom/edifact/segments/lin.rb', line 27

def starts_item?
  true
end

#to_json_hashObject



31
32
33
34
35
36
37
38
39
# File 'lib/eancom/edifact/segments/lin.rb', line 31

def to_json_hash
  hash = {}
  hash.merge!(ean: @item_identifier) if @item_identifier
  hash.merge!(action_request_notification_description_code: @action_request_notification_description_code) if @action_request_notification_description_code
  hash.merge!(item_type_identification_code: find_identifier(:item_type_identification_code)) if @item_type_identification_code
  hash.merge!(sub_line_indicator_code: @sub_line_indicator_code) if @sub_line_indicator_code
  hash.merge!(line_item_identifier_2: @line_item_identifier_2) if @line_item_identifier_2
  hash
end