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
  "digraph parse_tree {\n  size=\"8,5\"\n  node [shape = none];\n  edge [dir = none];\n  \#{@nodes.join \"\\n  \"}\n  \#{@edges.join \"\\n  \"}\n}\n  eodot\nend\n"