Class: Sinatra::Minify::Compressor
- Inherits:
-
Object
- Object
- Sinatra::Minify::Compressor
- Defined in:
- lib/sinatra/minify/compressor.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#package ⇒ Object
readonly
Returns the value of attribute package.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#build ⇒ Object
Rebuilds the minified .min.* files.
-
#clean ⇒ Object
Deletes all minified files.
-
#initialize(type, file, package) ⇒ Compressor
constructor
A new instance of Compressor.
Constructor Details
#initialize(type, file, package) ⇒ Compressor
Returns a new instance of Compressor.
6 7 8 9 10 11 12 13 |
# File 'lib/sinatra/minify/compressor.rb', line 6 def initialize(type, file, package) @type = type.to_s @file = file @package = package @command = :"minify_#{@type}" raise ArgumentError if not ['js', 'css'].include?(type) end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
4 5 6 |
# File 'lib/sinatra/minify/compressor.rb', line 4 def file @file end |
#package ⇒ Object (readonly)
Returns the value of attribute package.
4 5 6 |
# File 'lib/sinatra/minify/compressor.rb', line 4 def package @package end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
4 5 6 |
# File 'lib/sinatra/minify/compressor.rb', line 4 def type @type end |
Instance Method Details
#build ⇒ Object
Rebuilds the minified .min.* files.
16 17 18 19 |
# File 'lib/sinatra/minify/compressor.rb', line 16 def build File.open(file, 'w') { |f| f.write minify(concatenated) } file end |
#clean ⇒ Object
Deletes all minified files.
22 23 24 |
# File 'lib/sinatra/minify/compressor.rb', line 22 def clean File.unlink(file) if File.exists?(file) end |