class EDI::Diagram::Node

A Node is essentially the representation of a segment in a diagram. It comes in two flavors: Simple nodes (SNode) and T-nodes (TNode) which may have “tails”. “Node” is an abstract class - either create a SNode or a TNode.

Attributes

index[RW]
maxrep[R]
name[RW]
status[R]

Public Class Methods

create(name, status, rep) click to toggle source
name

The node’s name, e.g. the segment tag

status

A one-char string like ‘M’ (mandatory), ‘C’ (conditional)

rep

The max. number of repetitions of this node as allowed by the diagram specs.

# File lib/edi4r/diagrams.rb, line 374
def Node.create(name, status, rep)
  case name
  when /^SG\d+$/ # T-Node
    return TNode.new(name, status, rep)
  else         # Simple node
    return SNode.new(name, status, rep)
  end
end

Public Instance Methods

required?() click to toggle source
# File lib/edi4r/diagrams.rb, line 393
def required?
  (@status =~ /[MR]/) ? true : false
end
tail() click to toggle source

Returns nil for an SNode or a reference to the side branch (“tail”) of a TNode.

# File lib/edi4r/diagrams.rb, line 399
def tail
  return nil # Only TNode implements this non-trivially
end
to_s() click to toggle source
# File lib/edi4r/diagrams.rb, line 389
def to_s
  "%3d - %s, %s, %d" % [@index, @name, @status, @maxrep]
end