class BridgetownInlineSvg::RenderSvg

Attributes

attributes[R]

Public Class Methods

new(file_path, attributes) click to toggle source
# File lib/bridgetown-inline-svg/render_svg.rb, line 7
def initialize(file_path, attributes)
  @file_path = file_path
  @attributes = attributes
end

Public Instance Methods

call() click to toggle source
# 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

Private Instance Methods

file() click to toggle source
# File lib/bridgetown-inline-svg/render_svg.rb, line 20
def file
  @file ||= File.open(@file_path, File::RDONLY).read
end