Class: XmlPatch::XmlDocument
- Inherits:
-
Object
- Object
- XmlPatch::XmlDocument
- Defined in:
- lib/xml_patch/xml_document.rb
Instance Method Summary collapse
- #get_at(xpath) ⇒ Object
-
#initialize(xml) ⇒ XmlDocument
constructor
A new instance of XmlDocument.
- #remove_at!(xpath) ⇒ Object
- #to_xml ⇒ Object
Constructor Details
#initialize(xml) ⇒ XmlDocument
Returns a new instance of XmlDocument.
7 8 9 |
# File 'lib/xml_patch/xml_document.rb', line 7 def initialize(xml) @xml = xml end |
Instance Method Details
#get_at(xpath) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/xml_patch/xml_document.rb', line 21 def get_at(xpath) if block_given? nodes_at(xpath).each { |n| yield(n.name, node_attributes(n)) } end self end |
#remove_at!(xpath) ⇒ Object
15 16 17 18 19 |
# File 'lib/xml_patch/xml_document.rb', line 15 def remove_at!(xpath) nodes_at(xpath).each { |n| remove_node(n) } self end |
#to_xml ⇒ Object
11 12 13 |
# File 'lib/xml_patch/xml_document.rb', line 11 def to_xml xml_dom.to_xml end |