module Eancom module Edifact class DTM < Segment TAG = 'DTM'.freeze TYPE = :body.freeze attr_accessor :type, :date_time, :format def initialize( tag: nil, type:, date_time:, format: ) @tag = tag @type = type @date_time = date_time @format = format super(tag: @tag || TAG) end 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 def group_name 'date_time_messages' end def segment_type TYPE end private def identifier @identifier ||= structure.find(:type).dictionary[@type][:identifier] end end end end