Class | EDI::Diagram::NodeInstance |
In: |
lib/edi4r/diagrams.rb
|
Parent: | Object |
A given segment of a real message instance needs an instance counter in addition to its location in the diagram. This applies recursively to all segment groups in which it is embedded. This class is equipped with the additional attributes ("co-ordinates") of node instances.
We also use this class to determine the node instance of a segment when parsing a message. This is done in a sequential manner, starting from the current instance, by following the diagram branches up to the next matching segment tag/name.
A new NodeInstance is inititialized to a "virtual" 0th node before the first real node of the diagramm referenced by diag .
Returns this node instance’s level in the diagram. Note that special UN/EDIFACT rules about level 0 are acknowledged: level == 0 for mandatory SNode instances of the main branch with maxrep==1.
Main "workhorse": Seek for next matching segment tag/name
Starts at current location, follows the diagram downstream while searching for next matching segment.
Returns updated location (self) when found, nil otherwise.
Notes:
Move to the first node of the tail branch of this TNode. Returns self, or nil if there is no tail node.
Next: Move down if TNode and same as last match (another SG instance), else right. Move up if neither possible. Returns self, or nil if end of diag encountered.