Class: XmlPatch::DiffBuilder
- Inherits:
-
Object
- Object
- XmlPatch::DiffBuilder
- Defined in:
- lib/xml_patch/diff_builder.rb
Instance Attribute Summary collapse
-
#diff_document ⇒ Object
readonly
Returns the value of attribute diff_document.
Instance Method Summary collapse
-
#initialize ⇒ DiffBuilder
constructor
A new instance of DiffBuilder.
- #parse(patch) ⇒ Object
- #remove(xpath) ⇒ Object
Constructor Details
#initialize ⇒ DiffBuilder
Returns a new instance of DiffBuilder.
8 9 10 |
# File 'lib/xml_patch/diff_builder.rb', line 8 def initialize @diff_document = XmlPatch::DiffDocument.new end |
Instance Attribute Details
#diff_document ⇒ Object (readonly)
Returns the value of attribute diff_document.
6 7 8 |
# File 'lib/xml_patch/diff_builder.rb', line 6 def diff_document @diff_document end |
Instance Method Details
#parse(patch) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/xml_patch/diff_builder.rb', line 16 def parse(patch) patch.get_at('/diff/*') do |name, attrs| case name when 'remove' then remove(attrs['sel']) end end self end |
#remove(xpath) ⇒ Object
12 13 14 |
# File 'lib/xml_patch/diff_builder.rb', line 12 def remove(xpath) diff_document << XmlPatch::Operations::Remove.new(sel: xpath) end |