Class: Pura::Processing::Pipeline
- Inherits:
-
Object
- Object
- Pura::Processing::Pipeline
- Defined in:
- lib/pura/processing/pipeline.rb
Constant Summary collapse
- DEFAULT_FORMAT =
"jpg"
Instance Attribute Summary collapse
-
#destination ⇒ Object
readonly
Returns the value of attribute destination.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#loader ⇒ Object
readonly
Returns the value of attribute loader.
-
#operations ⇒ Object
readonly
Returns the value of attribute operations.
-
#processor ⇒ Object
readonly
Returns the value of attribute processor.
-
#saver ⇒ Object
readonly
Returns the value of attribute saver.
Instance Method Summary collapse
-
#call(save: true) ⇒ Object
Determines the destination and calls the processor.
-
#destination_format ⇒ Object
Determines the appropriate destination image format.
-
#initialize(options) ⇒ Pipeline
constructor
Initializes the pipeline with all the processing options.
-
#source_path ⇒ Object
Retrieves the source path on disk.
Constructor Details
#initialize(options) ⇒ Pipeline
Initializes the pipeline with all the processing options.
17 18 19 20 21 22 23 |
# File 'lib/pura/processing/pipeline.rb', line 17 def initialize() fail Error, "source file is not provided" unless [:source] .each do |name, value| instance_variable_set(:"@#{name}", value) end end |
Instance Attribute Details
#destination ⇒ Object (readonly)
Returns the value of attribute destination.
14 15 16 |
# File 'lib/pura/processing/pipeline.rb', line 14 def destination @destination end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
14 15 16 |
# File 'lib/pura/processing/pipeline.rb', line 14 def format @format end |
#loader ⇒ Object (readonly)
Returns the value of attribute loader.
14 15 16 |
# File 'lib/pura/processing/pipeline.rb', line 14 def loader @loader end |
#operations ⇒ Object (readonly)
Returns the value of attribute operations.
14 15 16 |
# File 'lib/pura/processing/pipeline.rb', line 14 def operations @operations end |
#processor ⇒ Object (readonly)
Returns the value of attribute processor.
14 15 16 |
# File 'lib/pura/processing/pipeline.rb', line 14 def processor @processor end |
#saver ⇒ Object (readonly)
Returns the value of attribute saver.
14 15 16 |
# File 'lib/pura/processing/pipeline.rb', line 14 def saver @saver end |
Instance Method Details
#call(save: true) ⇒ Object
Determines the destination and calls the processor.
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/pura/processing/pipeline.rb', line 26 def call(save: true) if save == false call_processor elsif destination handle_destination do call_processor(destination: destination) end else create_tempfile do |tempfile| call_processor(destination: tempfile.path) end end end |
#destination_format ⇒ Object
Determines the appropriate destination image format.
46 47 48 49 50 51 52 |
# File 'lib/pura/processing/pipeline.rb', line 46 def destination_format format = determine_format(destination) if destination format ||= self.format format ||= determine_format(source_path) if source_path format || DEFAULT_FORMAT end |
#source_path ⇒ Object
Retrieves the source path on disk.
41 42 43 |
# File 'lib/pura/processing/pipeline.rb', line 41 def source_path source if source.is_a?(String) end |