Class: BPL::Derivatives::Processors::Processor
- Inherits:
-
Object
- Object
- BPL::Derivatives::Processors::Processor
- Defined in:
- lib/bpl/derivatives/processors/processor.rb
Overview
Processors take a single input and produce a single output
Direct Known Subclasses
Instance Attribute Summary collapse
-
#directives ⇒ Object
Returns the value of attribute directives.
-
#object ⇒ Object
Returns the value of attribute object.
-
#output_file_service ⇒ Object
Returns the value of attribute output_file_service.
-
#source_path ⇒ Object
Returns the value of attribute source_path.
Instance Method Summary collapse
- #finalize_derivative_output(output_io) ⇒ Object
-
#initialize(object, directives, opts = {}) ⇒ Processor
constructor
A new instance of Processor.
-
#output_file ⇒ Object
deprecated
Deprecated.
Please use a PersistOutputFileService class to save an object
-
#output_file_id(name) ⇒ Object
This governs the output key sent to the persist file service while this is adequate for storing in Fedora, it’s not a great name for saving to the file system.
- #output_filename_for(_name) ⇒ Object
- #process ⇒ Object
Constructor Details
#initialize(object, directives, opts = {}) ⇒ Processor
Returns a new instance of Processor.
12 13 14 15 16 17 |
# File 'lib/bpl/derivatives/processors/processor.rb', line 12 def initialize(object, directives, opts = {}) self.object = object self.source_path = object.source_path self.directives = directives self.output_file_service = opts.fetch(:output_file_service, BPL::Derivatives.config.output_file_service) end |
Instance Attribute Details
#directives ⇒ Object
Returns the value of attribute directives.
4 5 6 |
# File 'lib/bpl/derivatives/processors/processor.rb', line 4 def directives @directives end |
#object ⇒ Object
Returns the value of attribute object.
4 5 6 |
# File 'lib/bpl/derivatives/processors/processor.rb', line 4 def object @object end |
#output_file_service ⇒ Object
Returns the value of attribute output_file_service.
4 5 6 |
# File 'lib/bpl/derivatives/processors/processor.rb', line 4 def output_file_service @output_file_service end |
#source_path ⇒ Object
Returns the value of attribute source_path.
4 5 6 |
# File 'lib/bpl/derivatives/processors/processor.rb', line 4 def source_path @source_path end |
Instance Method Details
#finalize_derivative_output(output_io) ⇒ Object
34 35 36 37 |
# File 'lib/bpl/derivatives/processors/processor.rb', line 34 def finalize_derivative_output(output_io) output_object = BPL::Derivatives::OutputObjectDecorator.new(output_io, object) output_file_service.call(output_object, directives) end |
#output_file ⇒ Object
Please use a PersistOutputFileService class to save an object
39 40 41 |
# File 'lib/bpl/derivatives/processors/processor.rb', line 39 def output_file raise NotImplementedError, "Processor is an abstract class. Utilize an implementation of a PersistOutputFileService class in #{self.class.name}" end |
#output_file_id(name) ⇒ Object
This governs the output key sent to the persist file service while this is adequate for storing in Fedora, it’s not a great name for saving to the file system.
26 27 28 |
# File 'lib/bpl/derivatives/processors/processor.rb', line 26 def output_file_id(name) [out_prefix, name].join('_') end |
#output_filename_for(_name) ⇒ Object
30 31 32 |
# File 'lib/bpl/derivatives/processors/processor.rb', line 30 def output_filename_for(_name) File.basename(source_path) end |
#process ⇒ Object
19 20 21 |
# File 'lib/bpl/derivatives/processors/processor.rb', line 19 def process raise "Processor is an abstract class. Implement `process' on #{self.class.name}" end |