Class: HTMLTree::Data
- Includes:
- TreeElement
- Defined in:
- lib/web/htmltools/element.rb,
lib/web/htmltools/xpath.rb
Overview
This is a TreeElement that represents leaf data nodes (CDATA, scripts, comments, processing directives). It forwards unknown messages to the content element, so it otherwise behaves like a String.
Instance Method Summary collapse
- #as_rexml_document(rparent = nil, context = {}) ⇒ Object
-
#attributes ⇒ Object
Return my (empty) attributes Hash.
-
#can_have_children? ⇒ Boolean
Return false because I have no children.
-
#children ⇒ Object
Return an empty collection because I have no children.
-
#data? ⇒ Boolean
Return true because I am a data Element.
-
#method_missing(sym, *args) ⇒ Object
Forward all other methods to my content, so I can otherwise behave like a String.
-
#tag ⇒ Object
Return my (empty) tag String.
- #to_s ⇒ Object
-
#write(io) ⇒ Object
Print me on the given IO stream.
Methods included from TreeElement
#add_child, #content, #dump, #each, #get_elements, #has_children?, #parent, #parent=, #remove_child, #rexml_match, #root
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args) ⇒ Object
Forward all other methods to my content, so I can otherwise behave like a String.
280 281 282 |
# File 'lib/web/htmltools/element.rb', line 280 def method_missing(sym, *args) @_content.method(sym).call(*args) end |
Instance Method Details
#as_rexml_document(rparent = nil, context = {}) ⇒ Object
43 44 45 |
# File 'lib/web/htmltools/xpath.rb', line 43 def as_rexml_document(rparent = nil, context = {}) rparent.add_text(@_content) end |
#attributes ⇒ Object
Return my (empty) attributes Hash.
267 |
# File 'lib/web/htmltools/element.rb', line 267 def attributes; {}; end |
#can_have_children? ⇒ Boolean
Return false because I have no children.
258 |
# File 'lib/web/htmltools/element.rb', line 258 def can_have_children?; false; end |
#children ⇒ Object
Return an empty collection because I have no children.
261 |
# File 'lib/web/htmltools/element.rb', line 261 def children; []; end |
#data? ⇒ Boolean
Return true because I am a data Element.
255 |
# File 'lib/web/htmltools/element.rb', line 255 def data?; true; end |
#tag ⇒ Object
Return my (empty) tag String.
264 |
# File 'lib/web/htmltools/element.rb', line 264 def tag; ''; end |
#to_s ⇒ Object
269 270 271 |
# File 'lib/web/htmltools/element.rb', line 269 def to_s @_content end |
#write(io) ⇒ Object
Print me on the given IO stream.
274 275 276 |
# File 'lib/web/htmltools/element.rb', line 274 def write(io) io << self end |