Class: DragonflySvg::Processors::SetTagValue

Inherits:
Object
  • Object
show all
Defined in:
lib/dragonfly_svg/processors/set_tag_value.rb

Instance Method Summary collapse

Instance Method Details

#call(content, xpath, value) ⇒ Object

Raises:



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/dragonfly_svg/processors/set_tag_value.rb', line 6

def call(content, xpath, value)
  raise UnsupportedFormat unless content.ext
  raise UnsupportedFormat unless SUPPORTED_FORMATS.include?(content.ext.downcase)

  doc = Nokogiri::XML(content.data)
  doc.xpath(xpath).each do |node|
    node.inner_html = value
  end

  content.update(doc.to_xml, 'name' => 'temp.svg')
end