Class: HTMLTree::Data
- Inherits:
-
Object
- Object
- HTMLTree::Data
- Includes:
- TreeElement
- Defined in:
- lib/html/element.rb,
lib/html/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, #has_children?, #parent, #parent=, #path, #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.
307 308 309 |
# File 'lib/html/element.rb', line 307 def method_missing(sym, *args) @_content.method(sym).call(*args) end |
Instance Method Details
#as_rexml_document(rparent = nil, context = {}) ⇒ Object
44 45 46 |
# File 'lib/html/xpath.rb', line 44 def as_rexml_document(rparent = nil, context = {}) rparent.add_text(@_content) end |
#attributes ⇒ Object
Return my (empty) attributes Hash.
294 |
# File 'lib/html/element.rb', line 294 def attributes; {}; end |
#can_have_children? ⇒ Boolean
Return false because I have no children.
285 |
# File 'lib/html/element.rb', line 285 def can_have_children?; false; end |
#children ⇒ Object
Return an empty collection because I have no children.
288 |
# File 'lib/html/element.rb', line 288 def children; []; end |
#data? ⇒ Boolean
Return true because I am a data Element.
282 |
# File 'lib/html/element.rb', line 282 def data?; true; end |
#tag ⇒ Object
Return my (empty) tag String.
291 |
# File 'lib/html/element.rb', line 291 def tag; ''; end |
#to_s ⇒ Object
296 297 298 |
# File 'lib/html/element.rb', line 296 def to_s @_content end |
#write(io) ⇒ Object
Print me on the given IO stream.
301 302 303 |
# File 'lib/html/element.rb', line 301 def write(io) io << self end |