Class: Nokolexbor::DocumentFragment
- Defined in:
- lib/nokolexbor/document_fragment.rb
Constant Summary
Constants inherited from Node
Node::ATTRIBUTE_NODE, Node::CDATA_SECTION_NODE, Node::COMMENT_NODE, Node::DOCUMENT_FRAG_NODE, Node::DOCUMENT_NODE, Node::DOCUMENT_TYPE_NODE, Node::ELEMENT_NODE, Node::ENTITY_NODE, Node::ENTITY_REF_NODE, Node::LOOKS_LIKE_XPATH, Node::NOTATION_NODE, Node::PI_NODE, Node::TEXT_NODE
Instance Attribute Summary
Attributes inherited from Node
Class Method Summary collapse
-
.parse(tags) ⇒ DocumentFragment
Create a DocumentFragment from
tags.
Instance Method Summary collapse
-
#fragment(data) ⇒ DocumentFragment
Create a DocumentFragment from
data. -
#initialize(document, tags = nil, ctx = nil) ⇒ DocumentFragment
constructor
Create a new DocumentFragment from
tags. -
#name ⇒ String
The name of DocumentFragment.
Methods inherited from Node
#<<, #add_class, #add_next_sibling, #add_previous_sibling, #after, #ancestors, #append_class, #at, #at_css, #at_xpath, #attributes, #before, #cdata?, #children=, #classes, #comment?, #css, #css_path, #document?, #each, #element?, #fragment?, #kwattr_add, #kwattr_append, #kwattr_remove, #kwattr_values, #matches?, #nokogiri_at_css, #nokogiri_css, #parent=, #prepend_child, #processing_instruction?, #remove_class, #replace, #search, #swap, #text?, #traverse, #value?, #wrap, #write_to, #xpath
Constructor Details
#initialize(document, tags = nil, ctx = nil) ⇒ DocumentFragment
Create a new Nokolexbor::DocumentFragment from tags.
If +ctx+ is present, it is used as a context node for the
subtree created.
16 17 18 19 20 21 22 23 |
# File 'lib/nokolexbor/document_fragment.rb', line 16 def initialize(document, = nil, ctx = nil) return self unless ctx ||= document node_set = ctx.parse() node_set.each { |child| child.parent = self } unless node_set.empty? nil end |
Class Method Details
.parse(tags) ⇒ DocumentFragment
Create a Nokolexbor::DocumentFragment from tags.
8 9 10 |
# File 'lib/nokolexbor/document_fragment.rb', line 8 def self.parse() new(Nokolexbor::Document.new, , nil) end |
Instance Method Details
#fragment(data) ⇒ DocumentFragment
Create a Nokolexbor::DocumentFragment from data.
38 39 40 |
# File 'lib/nokolexbor/document_fragment.rb', line 38 def fragment(data) document.fragment(data) end |
#name ⇒ String
Returns The name of Nokolexbor::DocumentFragment.
26 27 28 |
# File 'lib/nokolexbor/document_fragment.rb', line 26 def name "#document-fragment" end |