class SyntaxTree::Mermaid::FlowChart

of its nodes and links and renders them according to the mermaid syntax.
This is the main class that handles rendering a flowchart. It keeps track

def fetch(id)

Retrieve a node that has already been added to the flowchart by its id.
def fetch(id)
  nodes.fetch(id)
end

def initialize

def initialize
  @output = StringIO.new
  @output.puts("flowchart TD")
  @prefix = "  "
  @nodes = {}
  @links = []
end

def link(from, to, label = nil, type: :directed, color: nil)

Add a link to the flowchart between two nodes with an optional label.
def link(from, to, label = nil, type: :directed, color: nil)
  link = Link.new(from, to, label, type, color)
  links << link
  output.puts("#{prefix}#{link.render}")
  link
end

def node(id, label = " ", shape: :rectangle)

Add a node to the flowchart with an optional label.
def node(id, label = " ", shape: :rectangle)
  node = Node.new(id, label, shape)
  nodes[id] = node
  output.puts("#{prefix}#{nodes[id].render}")
  node
end

def render

Return the rendered flowchart.
def render
  links.each_with_index do |link, index|
    if link.color
      output.puts("#{prefix}linkStyle #{index} stroke:#{link.color}")
    end
  end
  output.string
end

def subgraph(label)

nodes will be rendered within the subgraph.
Add a subgraph to the flowchart. Within the given block, all of the
def subgraph(label)
  output.puts("#{prefix}subgraph #{Mermaid.escape(label)}")
  previous = prefix
  @prefix = "#{prefix}  "
  begin
    yield
  ensure
    @prefix = previous
    output.puts("#{prefix}end")
  end
end