class Infoboxer::Tree::Text
Represents plain text node.
Think of it like this: if you have paragraph “` Some paragraph with ''italic'' and [wikilink]. “` …then it will be parsed as a sequence of `[Text`, {Italic}, `Text`, {Wikilink}, `Text]`.
Attributes
raw_text[RW]
Text
fragment without decodint of HTML entities.
Public Class Methods
new(text, **params)
click to toggle source
Calls superclass method
Infoboxer::Tree::Node::new
# File lib/infoboxer/tree/text.rb, line 18 def initialize(text, **params) super(**params) @raw_text = +text end
Public Instance Methods
can_merge?(other)
click to toggle source
@private Internal, used by {Parser}
# File lib/infoboxer/tree/text.rb, line 35 def can_merge?(other) other.is_a?(String) || other.is_a?(Text) end
empty?()
click to toggle source
@private Internal, used by {Parser}
# File lib/infoboxer/tree/text.rb, line 53 def empty? raw_text.empty? end
merge!(other)
click to toggle source
@private Internal, used by {Parser}
# File lib/infoboxer/tree/text.rb, line 41 def merge!(other) @raw_text << case other when String then other when Text then other.raw_text else fail("Not mergeable into text: #{other.inspect}") end end
text()
click to toggle source
See {Node#text}
# File lib/infoboxer/tree/text.rb, line 24 def text @text ||= decode(@raw_text) end
to_tree(level = 0)
click to toggle source
See {Node#to_tree}
# File lib/infoboxer/tree/text.rb, line 29 def to_tree(level = 0) "#{indent(level)}#{text} <#{descr}>\n" end
Private Instance Methods
_eq(other)
click to toggle source
# File lib/infoboxer/tree/text.rb, line 59 def _eq(other) text == other.text end