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
Public Class Methods
Source
# File lib/rgl/rdot.rb 261 def initialize(name_or_ports = nil, label = nil) 262 if name_or_ports.nil? || name_or_ports.kind_of?(String) 263 @name = name_or_ports 264 @label = label 265 @ports = nil 266 else 267 @ports = name_or_ports 268 @name = nil 269 @label = nil 270 end 271 end
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
.
Public Instance Methods
Source
# File lib/rgl/rdot.rb 277 def to_s 278 if @ports.nil? || @ports.empty? 279 n = (name.nil? || name.empty?) ? '' : "<#{name}>" 280 n + ((n.empty? || label.nil? || label.empty?) ? '' : ' ') + label.to_s 281 else 282 '{' + @ports.collect { |p| p.to_s }.join(' | ') + '}' 283 end 284 end
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.