Class: Moxml::Adapter::CustomizedLibxml::Node
- Inherits:
-
Object
- Object
- Moxml::Adapter::CustomizedLibxml::Node
- Defined in:
- lib/moxml/adapter/customized_libxml/node.rb
Overview
Base wrapper class for LibXML nodes
This wrapper hides LibXML’s strict document ownership model, allowing nodes to be moved between documents transparently. Similar pattern to Ox adapter’s customized classes.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#native ⇒ Object
readonly
Returns the value of attribute native.
Instance Method Summary collapse
-
#==(other) ⇒ Object
(also: #eql?)
Compare wrappers based on their native nodes.
-
#document ⇒ Object
Get the document this node belongs to.
-
#document_present? ⇒ Boolean
Check if node has a document.
- #hash ⇒ Object
-
#initialize(native_node) ⇒ Node
constructor
A new instance of Node.
Constructor Details
#initialize(native_node) ⇒ Node
Returns a new instance of Node.
14 15 16 |
# File 'lib/moxml/adapter/customized_libxml/node.rb', line 14 def initialize(native_node) @native = native_node end |
Instance Attribute Details
#native ⇒ Object (readonly)
Returns the value of attribute native.
12 13 14 |
# File 'lib/moxml/adapter/customized_libxml/node.rb', line 12 def native @native end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
Compare wrappers based on their native nodes
19 20 21 22 23 24 |
# File 'lib/moxml/adapter/customized_libxml/node.rb', line 19 def ==(other) return false unless other other_native = other.respond_to?(:native) ? other.native : other @native == other_native end |
#document ⇒ Object
Get the document this node belongs to
38 39 40 |
# File 'lib/moxml/adapter/customized_libxml/node.rb', line 38 def document @native.doc if document_present? end |
#document_present? ⇒ Boolean
Check if node has a document
33 34 35 |
# File 'lib/moxml/adapter/customized_libxml/node.rb', line 33 def document_present? @native.respond_to?(:doc) && !@native.doc.nil? end |
#hash ⇒ Object
28 29 30 |
# File 'lib/moxml/adapter/customized_libxml/node.rb', line 28 def hash @native.hash end |