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 is
only one method you must implement to properly be a subclass:
#make, but #initialize may also be of use. #initialize accepts 3
arguments: the file that will be operated on (which is an instance of
File), a hash of options that were defined in has_attached_file's
style hash, and the Paperclip::Attachment itself. These are set as
instance variables that can be used within #make.
#make must return an instance of File (Tempfile is acceptable) which contains the results of the processing.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#attachment ⇒ Object
Returns the value of attribute attachment.
-
#file ⇒ Object
Returns the value of attribute file.
-
#options ⇒ Object
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #convert(arguments = nil, interpolation_values = {}) ⇒ Object
- #identify(arguments = nil, interpolation_values = {}) ⇒ Object
-
#initialize(file, options = {}, attachment = nil) ⇒ Processor
constructor
A new instance of Processor.
- #make ⇒ Object
Constructor Details
#initialize(file, options = {}, attachment = nil) ⇒ Processor
Returns a new instance of Processor.
23 24 25 26 27 |
# File 'lib/paperclip/processor.rb', line 23 def initialize(file, = {}, = nil) @file = file @options = @attachment = end |
Instance Attribute Details
#attachment ⇒ Object
Returns the value of attribute attachment.
21 22 23 |
# File 'lib/paperclip/processor.rb', line 21 def @attachment end |
#file ⇒ Object
Returns the value of attribute file.
21 22 23 |
# File 'lib/paperclip/processor.rb', line 21 def file @file end |
#options ⇒ Object
Returns the value of attribute options.
21 22 23 |
# File 'lib/paperclip/processor.rb', line 21 def @options end |
Class Method Details
.make(file, options = {}, attachment = nil) ⇒ Object
31 32 33 |
# File 'lib/paperclip/processor.rb', line 31 def self.make(file, = {}, = nil) new(file, , ).make end |
Instance Method Details
#convert(arguments = nil, interpolation_values = {}) ⇒ Object
35 36 37 |
# File 'lib/paperclip/processor.rb', line 35 def convert(arguments = nil, interpolation_values = {}) Paperclip::Commands::ImageMagick.convert(arguments, interpolation_values) end |
#identify(arguments = nil, interpolation_values = {}) ⇒ Object
39 40 41 |
# File 'lib/paperclip/processor.rb', line 39 def identify(arguments = nil, interpolation_values = {}) Paperclip::Commands::ImageMagick.identify(arguments, interpolation_values) end |
#make ⇒ Object
29 |
# File 'lib/paperclip/processor.rb', line 29 def make; end |