Class: GraphvizR::Node
- Inherits:
-
Object
- Object
- GraphvizR::Node
- Defined in:
- lib/graphviz_r.rb
Overview
This represents graphviz node.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#prop ⇒ Object
readonly
Returns the value of attribute prop.
Instance Method Summary collapse
-
#-(node) ⇒ Object
This generates a undirected edge from this node to given node.
- #<=>(other) ⇒ Object
-
#>>(node) ⇒ Object
This generates a directed edge from this node to given node.
- #[](prop) ⇒ Object
- #add_edge_on_dot(node) ⇒ Object
-
#initialize(name, port, dot) ⇒ Node
constructor
A new instance of Node.
- #to_dot ⇒ Object
- #to_sym ⇒ Object
Constructor Details
#initialize(name, port, dot) ⇒ Node
Returns a new instance of Node.
134 135 136 137 138 139 140 141 142 143 |
# File 'lib/graphviz_r.rb', line 134 def initialize(name, port, dot) @name = name @port = port || [] @dot = dot @prop = {} if !@port.empty? and @port[0].is_a? Array and @port[0][0].is_a? Hash @dot[@name] = @port[0][0] end end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
132 133 134 |
# File 'lib/graphviz_r.rb', line 132 def name @name end |
#prop ⇒ Object (readonly)
Returns the value of attribute prop.
132 133 134 |
# File 'lib/graphviz_r.rb', line 132 def prop @prop end |
Instance Method Details
#-(node) ⇒ Object
This generates a undirected edge from this node to given node.
152 153 154 155 |
# File 'lib/graphviz_r.rb', line 152 def -(node) @dot.undirected! add_edge_on_dot node end |
#<=>(other) ⇒ Object
170 171 172 |
# File 'lib/graphviz_r.rb', line 170 def <=>(other) @name <=> other.name end |
#>>(node) ⇒ Object
This generates a directed edge from this node to given node.
146 147 148 149 |
# File 'lib/graphviz_r.rb', line 146 def >>(node) @dot.directed! add_edge_on_dot node end |
#[](prop) ⇒ Object
164 165 166 167 168 |
# File 'lib/graphviz_r.rb', line 164 def [](prop) @dot[@name] = prop @prop.merge! prop self end |
#add_edge_on_dot(node) ⇒ Object
157 158 159 160 161 162 |
# File 'lib/graphviz_r.rb', line 157 def add_edge_on_dot(node) prop = @prop.merge node.prop edge = Edge.new(self, node, @dot, prop) @dot.add_edge edge edge end |
#to_dot ⇒ Object
178 179 180 181 182 |
# File 'lib/graphviz_r.rb', line 178 def to_dot name = @port.dup name.unshift @name name.map{|e| e.to_dot}.join(':') end |
#to_sym ⇒ Object
174 175 176 |
# File 'lib/graphviz_r.rb', line 174 def to_sym self end |