Class: BridgetownInlineSvg::RenderSvg

Inherits:
Object
  • Object
show all
Defined in:
lib/bridgetown-inline-svg/render_svg.rb

Direct Known Subclasses

RenderOptimizedSvg

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_path, attributes) ⇒ RenderSvg

Returns a new instance of RenderSvg.



7
8
9
10
# File 'lib/bridgetown-inline-svg/render_svg.rb', line 7

def initialize(file_path, attributes)
  @file_path = file_path
  @attributes = attributes
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



5
6
7
# File 'lib/bridgetown-inline-svg/render_svg.rb', line 5

def attributes
  @attributes
end

Instance Method Details

#callObject



12
13
14
15
16
# File 'lib/bridgetown-inline-svg/render_svg.rb', line 12

def call
  xml = Nokogiri::XML(file)
  attributes.each { |key, value| xml.root.set_attribute(key, value) }
  xml.root.to_xml
end