Class: Markbridge::AST::Text
Overview
Represents a text node (leaf node) in the AST. Text nodes contain the actual text content and cannot have children.
Instance Attribute Summary collapse
-
#text ⇒ String
readonly
The text content of this node.
Instance Method Summary collapse
-
#initialize(text) ⇒ Text
constructor
Create a new text node with the given content.
-
#merge(other) ⇒ Text
Merge another text node’s content into this one.
Constructor Details
#initialize(text) ⇒ Text
Create a new text node with the given content.
23 24 25 |
# File 'lib/markbridge/ast/text.rb', line 23 def initialize(text) @text = +text end |
Instance Attribute Details
#text ⇒ String (readonly)
Returns the text content of this node.
18 19 20 |
# File 'lib/markbridge/ast/text.rb', line 18 def text @text end |
Instance Method Details
#merge(other) ⇒ Text
Merge another text node’s content into this one. This mutates the current text node by appending the other’s text.
32 33 34 35 |
# File 'lib/markbridge/ast/text.rb', line 32 def merge(other) @text << other.text self end |