Class: God::DependencyGraph::Node
- Inherits:
-
Object
- Object
- God::DependencyGraph::Node
- Defined in:
- lib/god/dependency_graph.rb
Instance Attribute Summary collapse
-
#dependencies ⇒ Object
Returns the value of attribute dependencies.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #add(node) ⇒ Object
- #has_node?(node) ⇒ Boolean
-
#initialize(name) ⇒ Node
constructor
A new instance of Node.
Constructor Details
#initialize(name) ⇒ Node
Returns a new instance of Node.
27 28 29 30 |
# File 'lib/god/dependency_graph.rb', line 27 def initialize(name) self.name = name self.dependencies = [] end |
Instance Attribute Details
#dependencies ⇒ Object
Returns the value of attribute dependencies.
25 26 27 |
# File 'lib/god/dependency_graph.rb', line 25 def dependencies @dependencies end |
#name ⇒ Object
Returns the value of attribute name.
24 25 26 |
# File 'lib/god/dependency_graph.rb', line 24 def name @name end |
Instance Method Details
#add(node) ⇒ Object
32 33 34 |
# File 'lib/god/dependency_graph.rb', line 32 def add(node) self.dependencies << node unless self.dependencies.include?(node) end |
#has_node?(node) ⇒ Boolean
36 37 38 |
# File 'lib/god/dependency_graph.rb', line 36 def has_node?(node) (self == node) || self.dependencies.any { |x| x.has_node?(node) } end |