Class: Infoboxer::Tree::Text

Inherits:
Node
  • Object
show all
Defined in:
lib/infoboxer/tree/text.rb

Overview

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].

Direct Known Subclasses

Math

Instance Attribute Summary collapse

Attributes inherited from Node

#params, #parent

Instance Method Summary collapse

Methods inherited from Node

#==, #children, coder, def_readers, #first?, #index, #inspect, #next_siblings, #prev_siblings, #siblings, #text_, #to_s

Methods included from Navigation::Wikipath

#wikipath

Methods included from Navigation::Sections::Node

#in_sections

Methods included from Navigation::Shortcuts::Node

#bold?, #categories, #external_links, #heading?, #headings, #images, #infobox, #infoboxes, #italic?, #lists, #paragraphs, #tables, #templates, #wikilinks

Methods included from Navigation::Lookup::Node

#_lookup, #_lookup_children, #_lookup_next_siblings, #_lookup_parents, #_lookup_prev_sibling, #_lookup_prev_siblings, #_lookup_siblings, #_matches?, #lookup, #lookup_children, #lookup_next_siblings, #lookup_parents, #lookup_prev_sibling, #lookup_prev_siblings, #lookup_siblings, #matches?, #parent?

Constructor Details

#initialize(text, **params) ⇒ Text

Returns a new instance of Text.



18
19
20
21
# File 'lib/infoboxer/tree/text.rb', line 18

def initialize(text, **params)
  super(**params)
  @raw_text = +text
end

Instance Attribute Details

#raw_textObject

Text fragment without decodint of HTML entities.



16
17
18
# File 'lib/infoboxer/tree/text.rb', line 16

def raw_text
  @raw_text
end

Instance Method Details

#textObject

See Node#text



24
25
26
# File 'lib/infoboxer/tree/text.rb', line 24

def text
  @text ||= decode(@raw_text)
end

#to_tree(level = 0) ⇒ Object



29
30
31
# File 'lib/infoboxer/tree/text.rb', line 29

def to_tree(level = 0)
  "#{indent(level)}#{text} <#{descr}>\n"
end