Class: AVM::Node
- Inherits:
-
Nokogiri::XML::Node
- Object
- Nokogiri::XML::Node
- AVM::Node
- Defined in:
- lib/avm/node.rb
Overview
Delegate of Nokogiri::XML::Node which fixes XPath queries to use the correct namespace prefixes
Class Method Summary collapse
Instance Method Summary collapse
- #at_xpath(path) ⇒ Object
-
#initialize(xmp, node) ⇒ Node
constructor
A new instance of Node.
- #search(path) ⇒ Object
Constructor Details
#initialize(xmp, node) ⇒ Node
Returns a new instance of Node.
6 7 8 9 |
# File 'lib/avm/node.rb', line 6 def initialize(xmp, node) @xmp, @node = xmp, node super(@node) end |
Class Method Details
.from_nodeset(xmp, nodeset) ⇒ Object
23 24 25 |
# File 'lib/avm/node.rb', line 23 def self.from_nodeset(xmp, nodeset) nodeset.collect { |node| new(xmp, node) } end |
Instance Method Details
#at_xpath(path) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/avm/node.rb', line 11 def at_xpath(path) if node = @node.at_xpath(path, @xmp.namespaces) self.class.new(@xmp, node) else nil end end |
#search(path) ⇒ Object
19 20 21 |
# File 'lib/avm/node.rb', line 19 def search(path) self.class.from_nodeset(@xmp, @node.search(path, @xmp.namespaces)) end |