Class: Rumld::Tree

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/rumld/tree.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(graph, constant_names = []) ⇒ Tree



5
6
7
8
9
# File 'lib/rumld/tree.rb', line 5

def initialize( graph, constant_names = [])
  @graph = graph
  @constant_names = constant_names.uniq.sort
  build_nodes
end

Instance Attribute Details

#constant_namesObject (readonly)

Returns the value of attribute constant_names.



4
5
6
# File 'lib/rumld/tree.rb', line 4

def constant_names
  @constant_names
end

#graphObject (readonly)

Returns the value of attribute graph.



4
5
6
# File 'lib/rumld/tree.rb', line 4

def graph
  @graph
end

Instance Method Details

#all_nodesObject



25
26
27
# File 'lib/rumld/tree.rb', line 25

def all_nodes
  nodes.collect{|n| n.self_and_descendants}.flatten
end

#node_for(constant) ⇒ Object



29
30
31
# File 'lib/rumld/tree.rb', line 29

def node_for( constant )
  all_nodes.detect{|node| node.constant == constant || node.constant_name == constant}
end

#nodesObject



21
22
23
# File 'lib/rumld/tree.rb', line 21

def nodes
  @nodes ||= []
end

#to_dotObject



11
12
13
14
15
16
17
18
19
# File 'lib/rumld/tree.rb', line 11

def to_dot
  %(digraph uml_diagram {\n  graph[rotate=landscape, ratio=fill, overlap=false, splines=true]
    #{draw_nodes}
    #{draw_included_modules}
    #{draw_associations}
    #{draw_inheritence_edges}
  }
  )
end