Class: XmlPatch::Operations::Remove

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sel:) ⇒ Remove

Returns a new instance of Remove.



6
7
8
# File 'lib/xml_patch/operations/remove.rb', line 6

def initialize(sel:)
  @sel = sel.dup.freeze
end

Instance Attribute Details

#selObject (readonly)

Returns the value of attribute sel.



4
5
6
# File 'lib/xml_patch/operations/remove.rb', line 4

def sel
  @sel
end

Instance Method Details

#==(other) ⇒ Object



15
16
17
18
19
20
# File 'lib/xml_patch/operations/remove.rb', line 15

def ==(other)
  other.respond_to?(:operation) &&
    other.operation == operation &&
    other.respond_to?(:sel) &&
    other.sel == sel
end

#apply_to(doc) ⇒ Object



10
11
12
13
# File 'lib/xml_patch/operations/remove.rb', line 10

def apply_to(doc)
  doc.remove_at!(sel)
  doc
end

#operationObject



22
23
24
# File 'lib/xml_patch/operations/remove.rb', line 22

def operation
  :remove
end

#to_xmlObject



26
27
28
# File 'lib/xml_patch/operations/remove.rb', line 26

def to_xml
  %(<remove sel="#{sel}" />)
end