class RGL::DOT::Port
Ports are used when a Node
instance has its `shape' option set to record or Mrecord. Ports can be nested.
Attributes
label[RW]
name[RW]
ports[RW]
Public Class Methods
new(name = nil, label = nil)
click to toggle source
new(ports)
Create a new port with either an optional name and label or a set of nested ports.
A nil
value for name
is valid; otherwise, it must be a String or it will be interpreted as ports
.
# File lib/rgl/rdot.rb 208 def initialize(name_or_ports = nil, label = nil) 209 if name_or_ports.nil? || name_or_ports.kind_of?(String) 210 @name = name_or_ports 211 @label = label 212 @ports = nil 213 else 214 @ports = name_or_ports 215 @name = nil 216 @label = nil 217 end 218 end
Public Instance Methods
to_s()
click to toggle source
Returns a string representation of this port. If ports is a non-empty Enumerable, a nested ports representation is returned; otherwise, a name-label representation is returned.
# File lib/rgl/rdot.rb 224 def to_s 225 if @ports.nil? || @ports.empty? 226 n = (name.nil? || name.empty?) ? '' : "<#{name}>" 227 n + ((n.empty? || label.nil? || label.empty?) ? '' : ' ') + label.to_s 228 else 229 '{' + @ports.collect { |p| p.to_s }.join(' | ') + '}' 230 end 231 end