Class: EDI::Collection_HT

Inherits:
Object
  • Object
show all
Defined in:
lib/edi4r/rexml.rb,
lib/edi4r/edifact-rexml.rb

Instance Method Summary collapse

Instance Method Details

#to_din16557_4(xparent) ⇒ Object

NOTE: Makes sense only in the UN/EDIFACT context, so we list this method here.



215
216
217
218
219
# File 'lib/edi4r/edifact-rexml.rb', line 215

def to_din16557_4( xparent )
  header.to_din16557_4( xparent )
  each {|obj| obj.to_din16557_4( xparent )}
  trailer.to_din16557_4( xparent )
end

#to_xml(xel_parent) ⇒ Object



55
56
57
58
59
60
61
62
63
64
# File 'lib/edi4r/rexml.rb', line 55

def to_xml( xel_parent )
  xel  = REXML::Element.new( normalized_class_name ) 
  xel.attributes["name"]  = @name
  xel_parent.elements << xel

  xhd = to_xml_header( xel )
  each { |obj| obj.to_xml( xel ) }
  xtr = to_xml_trailer( xel )
  [xel, xhd, xtr] # You might want to add something ...
end

#to_xml_header(xparent) ⇒ Object



67
68
69
70
71
72
73
74
# File 'lib/edi4r/rexml.rb', line 67

def to_xml_header( xparent )
  if @header
    xparent << (xel = REXML::Element.new( 'Header' ))
    @header.to_xml( xel )
    return xel
  end
  nil
end

#to_xml_trailer(xparent) ⇒ Object



76
77
78
79
80
81
82
83
# File 'lib/edi4r/rexml.rb', line 76

def to_xml_trailer( xparent )
  if @trailer
    xparent << (xel = REXML::Element.new( 'Trailer' ))
    @trailer.to_xml( xel )
    return xel
  end
  nil
end