Class: XmlPatch::DiffBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/xml_patch/diff_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDiffBuilder

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_documentObject (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