Class: GraphManager
- Inherits:
-
Object
- Object
- GraphManager
- Defined in:
- lib/graph_manager.rb
Instance Method Summary collapse
- #add_edges(event) ⇒ Object
-
#initialize(options) ⇒ GraphManager
constructor
A new instance of GraphManager.
- #node_count ⇒ Object
- #output(*args) ⇒ Object
- #pop ⇒ Object
Constructor Details
#initialize(options) ⇒ GraphManager
Returns a new instance of GraphManager.
5 6 7 8 9 10 11 12 13 |
# File 'lib/graph_manager.rb', line 5 def initialize() @stack = ["start"] @edges = [] @options = @g = GraphViz.new(:G, :type => :digraph) @g.add_node("start") end |
Instance Method Details
#add_edges(event) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/graph_manager.rb', line 15 def add_edges(event) node = if @options[:show_path] "#{event.defined_class}##{event.method_id}\n#{event.path}".freeze else "#{event.defined_class}##{event.method_id}".freeze end edge = [@stack.last, node] @stack << node return if @edges.include?(edge) @edges << edge @g.add_edge(*@edges.last) end |
#node_count ⇒ Object
37 38 39 |
# File 'lib/graph_manager.rb', line 37 def node_count @g.node_count end |
#output(*args) ⇒ Object
33 34 35 |
# File 'lib/graph_manager.rb', line 33 def output(*args) @g.output(*args) end |
#pop ⇒ Object
41 42 43 |
# File 'lib/graph_manager.rb', line 41 def pop @stack.pop end |