Class: DotR::Node
Overview
Represents a node in a digraph. Instances of this class are created by calling Digraph#node.
Specify styles on this object by setting instance attributes. Possible attributes include ‘label’ and ‘shape’; the attribute names and possible values correspond to the style attributes described in the ‘dot’ manual.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #connection(other_node_name, style = {}, &block) ⇒ Object
-
#initialize(name, style = {}) {|_self| ... } ⇒ Node
constructor
:nodoc:.
-
#render_to(output_lines, indent) ⇒ Object
:nodoc:.
Methods included from Styled
Constructor Details
#initialize(name, style = {}) {|_self| ... } ⇒ Node
:nodoc:
128 129 130 131 132 133 134 |
# File 'lib/dotr.rb', line 128 def initialize(name, style={}, &block) #:nodoc: @name = name @connections = [] self.label = name style_attrs.update(style) yield self if block end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class DotR::Styled
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
126 127 128 |
# File 'lib/dotr.rb', line 126 def name @name end |
Instance Method Details
#connection(other_node_name, style = {}, &block) ⇒ Object
136 137 138 |
# File 'lib/dotr.rb', line 136 def connection(other_node_name, style={}, &block) @connections << Connection.new(self.name, other_node_name, style, &block) end |
#render_to(output_lines, indent) ⇒ Object
:nodoc:
140 141 142 143 |
# File 'lib/dotr.rb', line 140 def render_to(output_lines, indent) #:nodoc: output_lines << "#{indent}\"#{self.name}\"" + style + ";" @connections.each { |c| c.render_to(output_lines, indent) } end |