Class: SVGSprite::Extractor
- Inherits:
-
Object
- Object
- SVGSprite::Extractor
- Defined in:
- lib/svgsprite/extractor.rb
Class Method Summary collapse
-
.extract!(options) ⇒ Object
Class methods.
Instance Method Summary collapse
- #extract_svg_from(file) ⇒ Object
- #extract_svgs ⇒ Object
-
#initialize(options) ⇒ Extractor
constructor
Instance methods.
Constructor Details
#initialize(options) ⇒ Extractor
Instance methods
11 12 13 14 |
# File 'lib/svgsprite/extractor.rb', line 11 def initialize() @options = @input = @options[:input] end |
Class Method Details
.extract!(options) ⇒ Object
Class methods
6 7 8 |
# File 'lib/svgsprite/extractor.rb', line 6 def self.extract!() self.new().extract_svgs end |
Instance Method Details
#extract_svg_from(file) ⇒ Object
28 29 30 31 32 |
# 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 ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# 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 |