Class: Paperclip::Processors::Gzip
- Inherits:
-
DeflaterBase
- Object
- Paperclip::Processor
- DeflaterBase
- Paperclip::Processors::Gzip
- Defined in:
- lib/paperclip/processors/gzip.rb
Instance Method Summary collapse
-
#initialize(file, options = {}, attachment = nil) ⇒ Gzip
constructor
A new instance of Gzip.
- #make ⇒ Object
Constructor Details
#initialize(file, options = {}, attachment = nil) ⇒ Gzip
Returns a new instance of Gzip.
6 7 8 9 |
# File 'lib/paperclip/processors/gzip.rb', line 6 def initialize(file, = {}, = nil) super @gzip_options = @options[:gzip_options] || {} end |
Instance Method Details
#make ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/paperclip/processors/gzip.rb', line 11 def make level = @gzip_options[:level] strategy = @gzip_options[:strategy] dst = create_tempfile begin gz = Zlib::GzipWriter.new(dst, level, strategy) gz.write @file.read rescue ::Exception => e gz.close rescue nil raise e end gz.close @file.rewind dst.open dst end |