Class: EDI::MsgGroup

Inherits:
Collection_HT show all
Defined in:
lib/edi4r.rb,
lib/edi4r/rexml.rb

Direct Known Subclasses

E::MsgGroup

Instance Attribute Summary

Attributes inherited from Collection_HT

#header, #trailer

Attributes inherited from Object

#name, #parent, #root

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Collection_HT

#empty?, #root=, #to_din16557_4, #to_s, #to_xml, #to_xml_header, #to_xml_trailer, #validate

Methods inherited from Collection

#==, #[], #each, #find_all, #first, #index, #inspect, #last, #length, #map, #names, #normalized_class_name, #root=, #size

Constructor Details

#initialize(p, user_par = nil) ⇒ MsgGroup

Returns a new instance of MsgGroup.


573
574
575
576
# File 'lib/edi4r.rb', line 573

def initialize(p, user_par = nil)
  super(p, p.root, 'MsgGroup')  # ...

end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class EDI::Collection

Class Method Details

.parse_xml(p, xgrp) ⇒ Object

Note: Code is very similar to Message.parse_xml. Remove redundancy?


139
140
141
142
143
144
145
146
147
148
149
# File 'lib/edi4r/rexml.rb', line 139

def MsgGroup.parse_xml(p, xgrp)
  _header    = xgrp.elements["Header/Segment"]
  _trailer   = xgrp.elements["Trailer/Segment"]
  grp        = p.new_msggroup( Segment.parse_xml( p, _header ) )

  grp.header = Segment.parse_xml( grp, _header  ) if _header
  xgrp.elements.each('Message') {|xel| grp.add Message.parse_xml(grp, xel)}
  grp.trailer = Segment.parse_xml( grp, _trailer ) if _trailer

  grp
end

Instance Method Details

#add(msg) ⇒ Object

Add only Message objects to a message group!


590
591
592
593
# File 'lib/edi4r.rb', line 590

def add (msg)
  raise "Only Messages allowed here" unless msg.is_a? Message
  super
end

#each_BCDS(id, &b) ⇒ Object

:nodoc:


584
585
586
# File 'lib/edi4r.rb', line 584

def each_BCDS(id, &b) # :nodoc:
  @parent.each_BCDS(id, &b)
end

#fmt_of_DE(id) ⇒ Object

:nodoc:


579
580
581
# File 'lib/edi4r.rb', line 579

def fmt_of_DE(id) # :nodoc:
  @parent.fmt_of_DE(id)
end