Class: AwsCftTools::DependencyTree::Nodes
- Inherits:
-
Object
- Object
- AwsCftTools::DependencyTree::Nodes
- Includes:
- TSort
- Defined in:
- lib/aws_cft_tools/dependency_tree/nodes.rb
Overview
Manages a list of nodes or vertices. Edges pass from a filename node to a variable node or from a variable node to a filename node, but never from a filename node to a filename node or from a variable node to a variable node.
Instance Method Summary collapse
-
#dependencies_for(node) ⇒ Array<String>
Computes the direct dependencies of a node that are of the same type as the node.
-
#dependents_for(node) ⇒ Array<String>
Computes the things dependent on the given node.
-
#initialize ⇒ Nodes
constructor
A new instance of Nodes.
-
#make_link(from, to) ⇒ Object
Draws a directed link from
from
toto
.
Constructor Details
#initialize ⇒ Nodes
Returns a new instance of Nodes.
13 14 15 16 |
# File 'lib/aws_cft_tools/dependency_tree/nodes.rb', line 13 def initialize @nodes = default_hash @inverse_nodes = default_hash end |
Instance Method Details
#dependencies_for(node) ⇒ Array<String>
Computes the direct dependencies of a node that are of the same type as the node. If the node is a filename, then the returned nodes will be filenames. Likewise with variable names.
25 26 27 |
# File 'lib/aws_cft_tools/dependency_tree/nodes.rb', line 25 def dependencies_for(node) double_hop(@nodes, node.to_s) end |
#dependents_for(node) ⇒ Array<String>
Computes the things dependent on the given node. If the node is a filename, then the returned nodes will be filenames. Likewise with variable names.
36 37 38 |
# File 'lib/aws_cft_tools/dependency_tree/nodes.rb', line 36 def dependents_for(node) double_hop(@inverse_nodes, node.to_s) end |
#make_link(from, to) ⇒ Object
Draws a directed link from from
to to
.
45 46 47 48 |
# File 'lib/aws_cft_tools/dependency_tree/nodes.rb', line 45 def make_link(from, to) @nodes[from] << to @inverse_nodes[to] << from end |