Class: PaperclipCompression::Base
- Inherits:
-
Object
- Object
- PaperclipCompression::Base
- Defined in:
- lib/paperclip-compression/base.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(file, first_processor) ⇒ Base
constructor
A new instance of Base.
- #process_file ⇒ Object
Constructor Details
#initialize(file, first_processor) ⇒ Base
Returns a new instance of Base.
4 5 6 7 8 9 10 11 12 |
# File 'lib/paperclip-compression/base.rb', line 4 def initialize(file, first_processor) @file = file current_extension = File.extname(file.path) @basename = File.basename(file.path, current_extension) @dst = Paperclip::TempfileFactory.new.generate("#{@basename}.png") @dst_path = File.(@dst.path) @src_path = File.(@file.path) @first_processor = first_processor end |
Class Method Details
.make(file, first_processor, options = {}) ⇒ Object
14 15 16 |
# File 'lib/paperclip-compression/base.rb', line 14 def self.make(file, first_processor, = {}) new(file, first_processor, ).make end |
Instance Method Details
#process_file ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/paperclip-compression/base.rb', line 18 def process_file # Close output file so compressors which require exclusive file rights # work. @dst.close # Execute the child-compressor classes implementation of how to compress # the output compress # Re-open the output file so downstream paperclip-middleware may # read/write/etc. without having to re-open the file. @dst.open # Return the destination file for downstream paperclip processors. @dst end |