class SVGSprite::Extractor
Public Class Methods
extract!(options)
click to toggle source
Class methods
# File lib/svgsprite/extractor.rb, line 6 def self.extract!(options) self.new(options).extract_svgs end
new(options)
click to toggle source
Instance methods
# File lib/svgsprite/extractor.rb, line 11 def initialize(options) @options = options @input = @options[:input] end
Public Instance Methods
extract_svg_from(file)
click to toggle source
# File lib/svgsprite/extractor.rb, line 28 def extract_svg_from(file) doc = Nokogiri::HTML(file) node = doc.css('g').last.children node.to_s.strip end
extract_svgs()
click to toggle source
# File lib/svgsprite/extractor.rb, line 16 def extract_svgs Dir.glob("#{@input}/*.svg").map do |filepath| filename = File.basename(filepath, '.svg') file = File.open(filepath) { filename: filename, svg: extract_svg_from(file) } end end