Class: Graphviz::Node
- Inherits:
-
Object
- Object
- Graphviz::Node
- Defined in:
- lib/graphviz/graph.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#edges ⇒ Object
readonly
Returns the value of attribute edges.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #add_node(name, options = {}) ⇒ Object
- #connect(destination, options = {}) ⇒ Object
- #connected?(node) ⇒ Boolean
-
#initialize(graph, name, attributes = {}) ⇒ Node
constructor
A new instance of Node.
Constructor Details
#initialize(graph, name, attributes = {}) ⇒ Node
Returns a new instance of Node.
25 26 27 28 29 30 31 32 33 |
# File 'lib/graphviz/graph.rb', line 25 def initialize(graph, name, attributes = {}) @graph = graph @graph.nodes[name] = self @name = name @attributes = attributes @edges = [] end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
39 40 41 |
# File 'lib/graphviz/graph.rb', line 39 def attributes @attributes end |
#edges ⇒ Object (readonly)
Returns the value of attribute edges.
38 39 40 |
# File 'lib/graphviz/graph.rb', line 38 def edges @edges end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
35 36 37 |
# File 'lib/graphviz/graph.rb', line 35 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
36 37 38 |
# File 'lib/graphviz/graph.rb', line 36 def @options end |
Instance Method Details
#add_node(name, options = {}) ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/graphviz/graph.rb', line 53 def add_node(name, = {}) node = Node.new(@graph, name, ) connect(node) return node end |
#connect(destination, options = {}) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/graphviz/graph.rb', line 41 def connect(destination, = {}) edge = Edge.new(@graph, self, destination, ) @edges << edge return edge end |
#connected?(node) ⇒ Boolean
49 50 51 |
# File 'lib/graphviz/graph.rb', line 49 def connected?(node) return @edges.find{|edge| edge.destination == node} end |