Class: Arboretum::DocTree::Elements::CommentElement

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

Overview

A comment element of a doctree. CommentElements have no tags nor attributes nor contribute to document content, but are preserved in the tree Ex: <!– This is an example comment –>

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 = '') ⇒ CommentElement

Returns a new instance of CommentElement.



1250
1251
1252
1253
1254
1255
# File 'lib/arboretum/doctree.rb', line 1250

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

Instance Attribute Details

#textObject

Returns the value of attribute text.



1248
1249
1250
# File 'lib/arboretum/doctree.rb', line 1248

def text
  @text
end

Instance Method Details

#copyObject

CommentElement deep copy method



1258
1259
1260
# File 'lib/arboretum/doctree.rb', line 1258

def copy
  CommentElement.new(@text)
end

#dump_markup(type = :xml) ⇒ Object



1262
1263
1264
# File 'lib/arboretum/doctree.rb', line 1262

def dump_markup(type=:xml)
  "<!--#{self.text.gsub('&','&amp;').gsub('<', '&lt;').gsub('>','&gt;')}-->"
end

#to_sObject



1266
1267
1268
# File 'lib/arboretum/doctree.rb', line 1266

def to_s
  "<!--#{self.text}-->"
end