Class: Tinydot::Node
- Inherits:
-
Object
- Object
- Tinydot::Node
- Defined in:
- lib/tinydot/node.rb
Instance Attribute Summary collapse
-
#attrs ⇒ Object
readonly
Returns the value of attribute attrs.
-
#edges ⇒ Object
readonly
Returns the value of attribute edges.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #>>(other) ⇒ Object
-
#initialize(name, attrs) ⇒ Node
constructor
A new instance of Node.
- #to_dot ⇒ Object
Constructor Details
#initialize(name, attrs) ⇒ Node
Returns a new instance of Node.
5 6 7 8 9 |
# File 'lib/tinydot/node.rb', line 5 def initialize(name, attrs) @name = name @edges = [] @attrs = attrs || {} end |
Instance Attribute Details
#attrs ⇒ Object (readonly)
Returns the value of attribute attrs.
3 4 5 |
# File 'lib/tinydot/node.rb', line 3 def attrs @attrs end |
#edges ⇒ Object (readonly)
Returns the value of attribute edges.
3 4 5 |
# File 'lib/tinydot/node.rb', line 3 def edges @edges end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/tinydot/node.rb', line 3 def name @name end |
Instance Method Details
#<=>(other) ⇒ Object
16 17 18 19 |
# File 'lib/tinydot/node.rb', line 16 def <=>(other) @edges << Edge.new(self, other, dir: "both") other end |
#>>(other) ⇒ Object
11 12 13 14 |
# File 'lib/tinydot/node.rb', line 11 def >>(other) @edges << Edge.new(self, other) other end |
#to_dot ⇒ Object
21 22 23 24 25 26 |
# File 'lib/tinydot/node.rb', line 21 def to_dot quoted_attrs = %i(label color fillcolor fontname) @attrs.map do |k, v| quoted_attrs.include?(k) ? %(#{k} = "#{v}") : %(#{k} = #{v}) end.join(", ") end |