Class: Kin::Sprites::SassGenerator
- Inherits:
-
Object
- Object
- Kin::Sprites::SassGenerator
- Defined in:
- lib/kin/sprites/sass_generator.rb
Overview
Converts an IconSet to a SASS partial.
Constant Summary collapse
- TEMPLATE =
File.read(__FILE__).split(/^__END__/)[1]
Instance Method Summary collapse
-
#initialize(set, name) ⇒ SassGenerator
constructor
Creates a new Generator instance.
-
#to_sass(dir) ⇒ Object
Converts the icon set to a SASS partial.
Constructor Details
#initialize(set, name) ⇒ SassGenerator
Creates a new Generator instance.
19 20 21 |
# File 'lib/kin/sprites/sass_generator.rb', line 19 def initialize(set, name) @set, @name = set, name end |
Instance Method Details
#to_sass(dir) ⇒ Object
Converts the icon set to a SASS partial.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/kin/sprites/sass_generator.rb', line 32 def to_sass(dir) # Holds all the if/else statements. conditions = [] conditions << if_statement(@set[0], true) @set[1..-1].each { |icon| conditions << if_statement(icon) } # Permits supplying an offset, rather than an icon name. conditions << ' @else' conditions << ' !pos = !icon' conditions << '' # Put the data into the template. template = TEMPLATE.dup template.gsub!(/NAME/, @name) template.gsub!(/DIR/, dir) template.gsub!(/CONDITIONS/, conditions.join("\n")) template end |