Class: Paperclip::Processor
- Inherits:
-
Object
- Object
- Paperclip::Processor
- Defined in:
- lib/paperclip/processor.rb
Overview
Paperclip processors allow you to modify attached files when they are attached in any way you are able. Paperclip itself uses command-line programs for its included Thumbnail processor, but custom processors are not required to follow suit.
Processors are required to be defined inside the Paperclip module and are also required to be a subclass of Paperclip::Processor. There are only two methods you must implement to properly be a subclass: #initialize and #make. Initialize’s arguments are the file that will be operated on (which is an instance of File), and a hash of options that were defined in has_attached_file’s style hash.
All #make needs to do is return an instance of File (Tempfile is acceptable) which contains the results of the processing.
See Paperclip.run for more information about using command-line utilities from within Processors.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#file ⇒ Object
Returns the value of attribute file.
-
#options ⇒ Object
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(file, options = {}) ⇒ Processor
constructor
A new instance of Processor.
- #make ⇒ Object
Constructor Details
#initialize(file, options = {}) ⇒ Processor
Returns a new instance of Processor.
22 23 24 25 |
# File 'lib/paperclip/processor.rb', line 22 def initialize file, = {} @file = file @options = end |
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file.
20 21 22 |
# File 'lib/paperclip/processor.rb', line 20 def file @file end |
#options ⇒ Object
Returns the value of attribute options.
20 21 22 |
# File 'lib/paperclip/processor.rb', line 20 def @options end |
Class Method Details
.make(file, options = {}) ⇒ Object
30 31 32 |
# File 'lib/paperclip/processor.rb', line 30 def self.make file, = {} new(file, ).make end |
Instance Method Details
#make ⇒ Object
27 28 |
# File 'lib/paperclip/processor.rb', line 27 def make end |