Class: Predicator::Visitors::Dot

Inherits:
Visitor
  • Object
show all
Defined in:
lib/predicator/visitors/dot.rb

Constant Summary

Constants inherited from Visitor

Visitor::DISPATCH_CACHE

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDot

Returns a new instance of Dot.



6
7
8
9
# File 'lib/predicator/visitors/dot.rb', line 6

def initialize
  @nodes = []
  @edges = []
end

Instance Attribute Details

#edgesObject (readonly)

Returns the value of attribute edges.



4
5
6
# File 'lib/predicator/visitors/dot.rb', line 4

def edges
  @edges
end

#nodesObject (readonly)

Returns the value of attribute nodes.



4
5
6
# File 'lib/predicator/visitors/dot.rb', line 4

def nodes
  @nodes
end

Instance Method Details

#accept(node) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/predicator/visitors/dot.rb', line 11

def accept node
  super
  <<-eodot
digraph parse_tree {
  size="8,5"
  node [shape = none];
  edge [dir = none];
  #{@nodes.join "\n  "}
  #{@edges.join "\n  "}
}
  eodot
end