Class: SyntaxTree::Mermaid::Node
- Inherits:
-
Object
- Object
- SyntaxTree::Mermaid::Node
- Defined in:
- lib/syntax_tree/mermaid.rb
Overview
This class represents a node in a flowchart. Unlike the Link class, it can be used directly. It is the return value of the #node method, and is meant to be passed around to #link methods to create links between nodes.
Constant Summary collapse
- SHAPES =
i[circle rectangle rounded stadium].freeze
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#shape ⇒ Object
readonly
Returns the value of attribute shape.
Instance Method Summary collapse
-
#initialize(id, label, shape) ⇒ Node
constructor
A new instance of Node.
- #render ⇒ Object
Constructor Details
#initialize(id, label, shape) ⇒ Node
Returns a new instance of Node.
126 127 128 129 130 131 132 |
# File 'lib/syntax_tree/mermaid.rb', line 126 def initialize(id, label, shape) raise unless SHAPES.include?(shape) @id = id @label = label @shape = shape end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
124 125 126 |
# File 'lib/syntax_tree/mermaid.rb', line 124 def id @id end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
124 125 126 |
# File 'lib/syntax_tree/mermaid.rb', line 124 def label @label end |
#shape ⇒ Object (readonly)
Returns the value of attribute shape.
124 125 126 |
# File 'lib/syntax_tree/mermaid.rb', line 124 def shape @shape end |
Instance Method Details
#render ⇒ Object
134 135 136 137 |
# File 'lib/syntax_tree/mermaid.rb', line 134 def render left_bound, right_bound = bounds "#{id}#{left_bound}#{Mermaid.escape(label)}#{right_bound}" end |