Class: God::DependencyGraph
- Inherits:
-
Object
- Object
- God::DependencyGraph
- Defined in:
- lib/god/dependency_graph.rb,
lib/god/dependency_graph.rb
Defined Under Namespace
Classes: Node
Instance Attribute Summary collapse
-
#nodes ⇒ Object
Returns the value of attribute nodes.
Instance Method Summary collapse
- #add(a, b) ⇒ Object
-
#initialize ⇒ DependencyGraph
constructor
A new instance of DependencyGraph.
Constructor Details
#initialize ⇒ DependencyGraph
Returns a new instance of DependencyGraph.
5 6 7 |
# File 'lib/god/dependency_graph.rb', line 5 def initialize self.nodes = {} end |
Instance Attribute Details
#nodes ⇒ Object
Returns the value of attribute nodes.
3 4 5 |
# File 'lib/god/dependency_graph.rb', line 3 def nodes @nodes end |
Instance Method Details
#add(a, b) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/god/dependency_graph.rb', line 9 def add(a, b) node_a = self.nodes[a] || Node.new(a) node_b = self.nodes[b] || Node.new(b) node_a.add(node_b) self.nodes[a] ||= node_a self.nodes[b] ||= node_b end |