class SyntaxTree::Mermaid::Link

This class represents a link between two nodes in a flowchart. It is not meant to be interacted with directly, but rather used as a data structure by the FlowChart class.

Constants

COLORS
TYPES

Attributes

color[R]
from[R]
label[R]
to[R]
type[R]

Public Class Methods

new(from, to, label, type, color) click to toggle source
# File lib/syntax_tree/mermaid.rb, line 84
def initialize(from, to, label, type, color)
  raise unless TYPES.include?(type)
  raise if color && !COLORS.include?(color)

  @from = from
  @to = to
  @label = label
  @type = type
  @color = color
end

Public Instance Methods

render() click to toggle source
# File lib/syntax_tree/mermaid.rb, line 95
def render
  left_side, right_side, full_side = sides

  if label
    escaped = Mermaid.escape(label)
    "#{from.id} #{left_side} #{escaped} #{right_side} #{to.id}"
  else
    "#{from.id} #{full_side} #{to.id}"
  end
end