Class EDI::Diagram::NodeInstance
In: lib/edi4r/diagrams.rb
Parent: Object

NodeInstance

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.

Methods

down!   index   inst_cnt   is_tnode?   level   maxrep   name   new   next!   node   rep   right!   seek!   sg_name   status   up!  

Public Class methods

A new NodeInstance is inititialized to a "virtual" 0th node before the first real node of the diagramm referenced by diag .

Public Instance methods

Returns the node’s instance counter

true if this is a TNode (trigger node/segment)

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.

Delegate some getters to the underlying diagram node:

 index, maxrep, name, status

Returns diagram node corresponding to this instance’s co-ordinates

rep()

Alias for inst_cnt

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:

  1. Search fails when trying to skip a required node
  2. Search fails if we hit the end of the diagram before a match
  3. We might need to loop through segment groups repeatedly!

Returns the branch name (segment group name)

Protected Instance methods

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.

Move to the right of the current node in this branch. Returns self, or nil if already at the branch end.

Move "up" to the TNode of this branch. Returns self, or nil if already at the top.

[Validate]