Class: CodeMapper::Output::Dot

Inherits:
Object
  • Object
show all
Defined in:
lib/code_mapper/output/dot.rb

Instance Method Summary collapse

Constructor Details

#initialize(io) ⇒ Dot

Returns a new instance of Dot.



6
7
8
9
10
11
12
# File 'lib/code_mapper/output/dot.rb', line 6

def initialize(io)
  @io = io
  @stack = []

  @graph = Graphviz::Graph.new('CodeMapper')
  @graph.attributes[:rankdir] = 'LR'
end

Instance Method Details

#doneObject



29
30
31
# File 'lib/code_mapper/output/dot.rb', line 29

def done
  @io.puts @graph.to_dot
end

#pop(tp, normalized_class_name) ⇒ Object



25
26
27
# File 'lib/code_mapper/output/dot.rb', line 25

def pop(tp, normalized_class_name)
  @stack.pop
end

#push(tp, normalized_class_name) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/code_mapper/output/dot.rb', line 14

def push(tp, normalized_class_name)
  node = @graph.add_node("#{normalized_class_name}.#{tp.method_id.to_s}")
  node.attributes[:shape] = 'rectangle'

  if @stack != []
    @stack.last.connect(node)
  end

  @stack << node
end