Class: Nokogiri::XML::Document

Inherits:
Node
  • Object
show all
Defined in:
lib/nokogiri/xml/document.rb

Direct Known Subclasses

HTML::Document

Constant Summary

Constants inherited from Node

Node::ATTRIBUTE_DECL, Node::CDATA_SECTION_NODE, Node::COMMENT_NODE, Node::DOCB_DOCUMENT_NODE, Node::DOCUMENT_NODE, Node::DTD_NODE, Node::ELEMENT_DECL, Node::ENTITY_DECL, Node::HTML_DOCUMENT_NODE, Node::NAMESPACE_DECL, Node::XINCLUDE_END, Node::XINCLUDE_START

Instance Method Summary collapse

Methods inherited from Node

#[], #after, #at, #before, #cdata?, #children, #collect_namespaces, #comment?, #content=, #css, #css_path, #decorate!, #has_attribute?, #html?, #next, #remove, #search, #set_attribute, #text, #to_html, #traverse, #xml?, #xpath

Instance Method Details

#decorate(node) ⇒ Object

Apply any decorators to node



14
15
16
17
18
19
# File 'lib/nokogiri/xml/document.rb', line 14

def decorate(node)
  key = node.class.name.split('::').last.downcase
  decorators[key].each do |klass|
    node.extend(klass)
  end
end

#decoratorsObject



4
5
6
# File 'lib/nokogiri/xml/document.rb', line 4

def decorators
  @decorators ||= Hash.new { |h,k| h[k] = [] }
end

#nameObject



8
9
10
# File 'lib/nokogiri/xml/document.rb', line 8

def name
  'document'
end

#namespacesObject



25
26
27
# File 'lib/nokogiri/xml/document.rb', line 25

def namespaces
  root ? root.collect_namespaces : {}
end

#to_xmlObject



21
22
23
# File 'lib/nokogiri/xml/document.rb', line 21

def to_xml
  serialize
end