Class: Mxrb::Architecture::Graph
- Inherits:
-
Object
- Object
- Mxrb::Architecture::Graph
- Defined in:
- lib/mxrb/architecture/graph.rb
Instance Attribute Summary collapse
-
#edges ⇒ Object
readonly
Returns the value of attribute edges.
-
#nodes ⇒ Object
readonly
Returns the value of attribute nodes.
Instance Method Summary collapse
- #dependencies_of(node) ⇒ Object
- #find(module_name, kind, name) ⇒ Object
-
#initialize(definition) ⇒ Graph
constructor
A new instance of Graph.
- #node_id(module_name, kind, name) ⇒ Object
Constructor Details
#initialize(definition) ⇒ Graph
Returns a new instance of Graph.
11 12 13 14 15 16 |
# File 'lib/mxrb/architecture/graph.rb', line 11 def initialize(definition) @definition = definition @nodes = {} @edges = [] build end |
Instance Attribute Details
#edges ⇒ Object (readonly)
Returns the value of attribute edges.
9 10 11 |
# File 'lib/mxrb/architecture/graph.rb', line 9 def edges @edges end |
#nodes ⇒ Object (readonly)
Returns the value of attribute nodes.
9 10 11 |
# File 'lib/mxrb/architecture/graph.rb', line 9 def nodes @nodes end |
Instance Method Details
#dependencies_of(node) ⇒ Object
26 27 28 |
# File 'lib/mxrb/architecture/graph.rb', line 26 def dependencies_of(node) @edges.select { _1.from == node.id }.filter_map { @nodes[_1.to] } end |
#find(module_name, kind, name) ⇒ Object
22 23 24 |
# File 'lib/mxrb/architecture/graph.rb', line 22 def find(module_name, kind, name) @nodes[node_id(module_name, kind, name)] end |
#node_id(module_name, kind, name) ⇒ Object
18 19 20 |
# File 'lib/mxrb/architecture/graph.rb', line 18 def node_id(module_name, kind, name) "#{module_name}::#{kind}::#{name}" end |