Class: Eancom::Edifact::DTM
- Defined in:
- lib/eancom/edifact/segments/dtm.rb
Constant Summary collapse
- TAG =
'DTM'.freeze
- TYPE =
:body.freeze
Instance Attribute Summary collapse
-
#date_time ⇒ Object
Returns the value of attribute date_time.
-
#format ⇒ Object
Returns the value of attribute format.
-
#type ⇒ Object
Returns the value of attribute type.
Attributes inherited from Segment
Instance Method Summary collapse
- #group_name ⇒ Object
-
#initialize(tag: nil, type:, date_time:, format:) ⇒ DTM
constructor
A new instance of DTM.
- #segment_type ⇒ Object
- #to_json_hash ⇒ Object
Methods inherited from Segment
#array, 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, type:, date_time:, format:) ⇒ DTM
Returns a new instance of DTM.
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/eancom/edifact/segments/dtm.rb', line 9 def initialize( tag: nil, type:, date_time:, format: ) @tag = tag @type = type @date_time = date_time @format = format super(tag: @tag || TAG) end |
Instance Attribute Details
#date_time ⇒ Object
Returns the value of attribute date_time.
7 8 9 |
# File 'lib/eancom/edifact/segments/dtm.rb', line 7 def date_time @date_time end |
#format ⇒ Object
Returns the value of attribute format.
7 8 9 |
# File 'lib/eancom/edifact/segments/dtm.rb', line 7 def format @format end |
#type ⇒ Object
Returns the value of attribute type.
7 8 9 |
# File 'lib/eancom/edifact/segments/dtm.rb', line 7 def type @type end |
Instance Method Details
#group_name ⇒ Object
32 33 34 |
# File 'lib/eancom/edifact/segments/dtm.rb', line 32 def group_name 'date_time_messages' end |
#segment_type ⇒ Object
36 37 38 |
# File 'lib/eancom/edifact/segments/dtm.rb', line 36 def segment_type TYPE end |
#to_json_hash ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/eancom/edifact/segments/dtm.rb', line 23 def to_json_hash hash = { identifier => {} } hash[identifier].merge!({ date_time: @date_time }) if @date_time hash.merge!({ identifier: @identifier }) if @identifier hash = {} if hash[identifier].empty? hash end |