class BridgetownInlineSvg::RenderOptimizedSvg

Constants

PLUGINS
PLUGINS_BLOCKLIST

Private Class Methods

set(params) click to toggle source
# File lib/bridgetown-inline-svg/render_optimized_svg.rb, line 21
def self.set(params)
  @@params = params
end

Public Instance Methods

call() click to toggle source
# File lib/bridgetown-inline-svg/render_optimized_svg.rb, line 13
def call
  SvgOptimizer.optimize(file, [create_plugin!] + PLUGINS)
end

Private Instance Methods

create_plugin!() click to toggle source
# File lib/bridgetown-inline-svg/render_optimized_svg.rb, line 19
def create_plugin!
  mod = Class.new(SvgOptimizer::Plugins::Base) {
    def self.set(params)
      @@params = params
    end

    def process
      @@params.each { |key, value| xml.root.set_attribute(key, value) }
      xml
    end
  }
  mod.set(@attributes)
  mod
end
process() click to toggle source
# File lib/bridgetown-inline-svg/render_optimized_svg.rb, line 25
def process
  @@params.each { |key, value| xml.root.set_attribute(key, value) }
  xml
end