Class: SyntaxTree::MermaidVisitor

Inherits:
FieldVisitor show all
Defined in:
lib/syntax_tree/mermaid_visitor.rb

Overview

This visitor transforms the AST into a mermaid flow chart.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BasicVisitor

valid_visit_methods, #visit, #visit_all, #visit_child_nodes, visit_method, visit_methods

Constructor Details

#initializeMermaidVisitor

Returns a new instance of MermaidVisitor.



8
9
10
11
# File 'lib/syntax_tree/mermaid_visitor.rb', line 8

def initialize
  @flowchart = Mermaid.flowchart
  @target = nil
end

Instance Attribute Details

#flowchartObject (readonly)

Returns the value of attribute flowchart.



6
7
8
# File 'lib/syntax_tree/mermaid_visitor.rb', line 6

def flowchart
  @flowchart
end

#targetObject (readonly)

Returns the value of attribute target.



6
7
8
# File 'lib/syntax_tree/mermaid_visitor.rb', line 6

def target
  @target
end

Instance Method Details

#visit_program(node) ⇒ Object



13
14
15
16
# File 'lib/syntax_tree/mermaid_visitor.rb', line 13

def visit_program(node)
  super
  flowchart.render
end