class Eancom::Edifact::DTM

Constants

TAG
TYPE

Attributes

date_time[RW]
format[RW]
type[RW]

Public Class Methods

new( tag: nil, type:, date_time:, format: ) click to toggle source
Calls superclass method Eancom::Edifact::Segment::new
# 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

Public Instance Methods

group_name() click to toggle source
# File lib/eancom/edifact/segments/dtm.rb, line 32
def group_name
  'date_time_messages'
end
segment_type() click to toggle source
# File lib/eancom/edifact/segments/dtm.rb, line 36
def segment_type
  TYPE
end
to_json_hash() click to toggle source
# 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

Private Instance Methods

identifier() click to toggle source
# File lib/eancom/edifact/segments/dtm.rb, line 42
def identifier
  @identifier ||= structure.find(:type).dictionary[@type][:identifier]
end