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
Returns a new instance of SVGProcessor.
5 6 7 8 9 |
# File 'lib/svg_processor.rb', line 5 def initialize(path, prefix, sprite_path) @path = path @prefix = prefix @sprite_path = sprite_path end |
Instance Method Details
#rebuild ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/svg_processor.rb', line 11 def rebuild @svgs = Dir["#{@path}/*.svg"].map { |file| get_svg(file) } logger.debug "rebuilding: #{@svgs.length} svgs found" @symbols = @svgs.map { |svg| convert_to_symbol(svg) } @symbol_string = @symbols.join("\n") if @sprite_path != nil File.write(@sprite_path, "<svg xmlns=\"http://www.w3.org/2000/svg\">#{@symbol_string}</svg>") end end |
#to_s ⇒ Object
23 24 25 |
# File 'lib/svg_processor.rb', line 23 def to_s @symbol_string end |