Class: Eancom::Edifact::GIN

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

Constant Summary collapse

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

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, object_identification_code_qualifier:, object_identifier_1: nil, object_identifier_2: nil, object_identifier_3: nil, object_identifier_4: nil, object_identifier_5: nil) ⇒ GIN

Returns a new instance of GIN.



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

def initialize(
  tag: nil,
  object_identification_code_qualifier:,
  object_identifier_1: nil,
  object_identifier_2: nil,
  object_identifier_3: nil,
  object_identifier_4: nil,
  object_identifier_5: nil
)
  @tag = tag
  @object_identification_code_qualifier = object_identification_code_qualifier
  @object_identifier_1 = object_identifier_1
  @object_identifier_2 = object_identifier_2
  @object_identifier_3 = object_identifier_3
  @object_identifier_4 = object_identifier_4
  @object_identifier_5 = object_identifier_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/gin.rb', line 7

def segment_type
  @segment_type
end

Instance Method Details

#to_json_hashObject



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

def to_json_hash
  hash = {}
  hash.merge!(object_identification_code_qualifier: @object_identification_code_qualifier) if @object_identification_code_qualifier
  hash.merge!(object_identifier_1: @object_identifier_1) if @object_identifier_1
  hash.merge!(object_identifier_2: @object_identifier_2) if @object_identifier_2
  hash.merge!(object_identifier_3: @object_identifier_3) if @object_identifier_3
  hash.merge!(object_identifier_4: @object_identifier_4) if @object_identifier_4
  hash.merge!(object_identifier_5: @object_identifier_5) if @object_identifier_5
  hash
end