Class: God::DependencyGraph::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/god/dependency_graph.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#dependenciesObject

Returns the value of attribute dependencies.



25
26
27
# File 'lib/god/dependency_graph.rb', line 25

def dependencies
  @dependencies
end

#nameObject

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

Returns:

  • (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