Class: CssSpriter::StylesheetBuilder
- Inherits:
-
Object
- Object
- CssSpriter::StylesheetBuilder
- Defined in:
- lib/css-spriter/stylesheet_builder.rb
Instance Method Summary collapse
- #cleanup ⇒ Object
- #css ⇒ Object
-
#initialize(dir) ⇒ StylesheetBuilder
constructor
A new instance of StylesheetBuilder.
- #output_file(file) ⇒ Object
- #write ⇒ Object
Constructor Details
#initialize(dir) ⇒ StylesheetBuilder
Returns a new instance of StylesheetBuilder.
3 4 5 6 |
# File 'lib/css-spriter/stylesheet_builder.rb', line 3 def initialize(dir) @dir = dir @output_file = @dir + "/sprite.css" end |
Instance Method Details
#cleanup ⇒ Object
20 21 22 |
# File 'lib/css-spriter/stylesheet_builder.rb', line 20 def cleanup File.delete(@output_file) rescue nil end |
#css ⇒ Object
12 13 14 |
# File 'lib/css-spriter/stylesheet_builder.rb', line 12 def css @css ||= Dir.glob(@dir + "/**/fragment.css").inject("") {|acc, f| acc + File.read(f)} end |
#output_file(file) ⇒ Object
8 9 10 |
# File 'lib/css-spriter/stylesheet_builder.rb', line 8 def output_file(file) @output_file = file end |
#write ⇒ Object
16 17 18 |
# File 'lib/css-spriter/stylesheet_builder.rb', line 16 def write File.open(@output_file, 'w') {|f| f.write(css)} end |