Class: Mxrb::Architecture::Graph

Inherits:
Object
  • Object
show all
Defined in:
lib/mxrb/architecture/graph.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#edgesObject (readonly)

Returns the value of attribute edges.



9
10
11
# File 'lib/mxrb/architecture/graph.rb', line 9

def edges
  @edges
end

#nodesObject (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