Class: SVGProcessor
- Inherits:
-
Object
- Object
- SVGProcessor
- Defined in:
- lib/svg_processor.rb
Instance Method Summary collapse
-
#initialize(path, prefix, sprite_path) ⇒ SVGProcessor
constructor
A new instance of SVGProcessor.
- #rebuild ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(path, prefix, sprite_path) ⇒ SVGProcessor
4 5 6 7 8 |
# File 'lib/svg_processor.rb', line 4 def initialize(path, prefix, sprite_path) @path = path @prefix = prefix @sprite_path = sprite_path end |
Instance Method Details
#rebuild ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/svg_processor.rb', line 10 def rebuild @svgs = Dir["#{@path}/*"].map { |file| get_svg(file) } puts "rebuilding: #{@svgs.length} svgs found" @symbols = @svgs.map { |svg| convert_to_symbol(svg) } @symbol_string = @symbols.join("\n") if @sprite_path != nil File.write("./source/images/#{@sprite_path}", "<svg xmlns=\"http://www.w3.org/2000/svg\">#{@symbol_string}</svg>") end end |
#to_s ⇒ Object
22 23 24 |
# File 'lib/svg_processor.rb', line 22 def to_s @symbol_string end |