Class: Arboretum::DocTree::Elements::TextElement

Inherits:
Element
  • Object
show all
Defined in:
lib/arboretum/doctree.rb

Overview

A text element of a doctree. TextElements have no tags nor attributes and are only meant to represent document content Ex: <p>Hello World</p> is a tagged element ‘p’ with a single text element child with text “Hello World”

Direct Known Subclasses

CounterElement

Instance Attribute Summary collapse

Attributes inherited from Element

#break_within, #children, #history, #incrementers, #library, #parent, #resetters, #sibling_next, #sibling_prev, #tree_residence

Instance Method Summary collapse

Methods inherited from Element

#ancestors, #ancestors_reverse, #append_child, #append_sibling, #can_have_children?, #content, #count, #counter, create, #descendants, #detach, #find, #find_first, #find_first_n, #following_siblings, #graft_first_onto, #graft_last_onto, #graft_onto, #has_children?, #index_in_parent, #insert_child, #inspect, #lib_add, #lib_get, #listing, #matches_rule?, #overwrite!, #preceding_siblings, #preceding_siblings_reverse, #prepend_child, #prepend_sibling, #reset, #set_children!, #set_parent!, #set_sibling_next!, #set_sibling_prev!, stitch!, #text_elements, #text_string, #to_tree, #unwrap_children, #update_tree_residence

Methods included from Loggable

#log, #log_string

Methods included from Contextualized

#swap, #wrap

Constructor Details

#initialize(text = '') ⇒ TextElement

Returns a new instance of TextElement.



1218
1219
1220
1221
1222
1223
# File 'lib/arboretum/doctree.rb', line 1218

def initialize(text='')
  super()
  
  # Element text
  @text = text  # String
end

Instance Attribute Details

#textObject



1230
1231
1232
# File 'lib/arboretum/doctree.rb', line 1230

def text
  @text
end

Instance Method Details

#copyObject

TextElement deep copy method



1226
1227
1228
# File 'lib/arboretum/doctree.rb', line 1226

def copy
  TextElement.new(@text)
end

#dump_markup(type = :xml) ⇒ Object



1234
1235
1236
# File 'lib/arboretum/doctree.rb', line 1234

def dump_markup(type=:xml)
  self.text.gsub('&','&amp;').gsub('<', '&lt;').gsub('>','&gt;')
end

#to_sObject



1238
1239
1240
# File 'lib/arboretum/doctree.rb', line 1238

def to_s
  self.text.inspect
end