Class: Hydra::Derivatives::Processor
- Inherits:
-
Object
- Object
- Hydra::Derivatives::Processor
- Defined in:
- lib/hydra/derivatives/processor.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#directives ⇒ Object
Returns the value of attribute directives.
-
#object ⇒ Object
Returns the value of attribute object.
-
#source_name ⇒ Object
Returns the value of attribute source_name.
Instance Method Summary collapse
-
#initialize(obj, source_name, directives) ⇒ Processor
constructor
A new instance of Processor.
- #output_file(path) ⇒ Object
- #output_file_id(name) ⇒ Object
- #process ⇒ Object
- #source_file ⇒ Object
Constructor Details
#initialize(obj, source_name, directives) ⇒ Processor
Returns a new instance of Processor.
6 7 8 9 10 |
# File 'lib/hydra/derivatives/processor.rb', line 6 def initialize(obj, source_name, directives) self.object = obj self.source_name = source_name self.directives = directives end |
Instance Attribute Details
#directives ⇒ Object
Returns the value of attribute directives.
4 5 6 |
# File 'lib/hydra/derivatives/processor.rb', line 4 def directives @directives end |
#object ⇒ Object
Returns the value of attribute object.
4 5 6 |
# File 'lib/hydra/derivatives/processor.rb', line 4 def object @object end |
#source_name ⇒ Object
Returns the value of attribute source_name.
4 5 6 |
# File 'lib/hydra/derivatives/processor.rb', line 4 def source_name @source_name end |
Instance Method Details
#output_file(path) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/hydra/derivatives/processor.rb', line 20 def output_file(path) # first, check for a defined file output_file = if object.attached_files[path] object.attached_files[path] else ActiveFedora::File.new("#{object.uri}/#{path}").tap do |file| object.attach_file(file, path) end end end |
#output_file_id(name) ⇒ Object
16 17 18 |
# File 'lib/hydra/derivatives/processor.rb', line 16 def output_file_id(name) [source_name, name].join('_') end |
#process ⇒ Object
12 13 14 |
# File 'lib/hydra/derivatives/processor.rb', line 12 def process raise "Processor is an abstract class. Implement `process' on #{self.class.name}" end |
#source_file ⇒ Object
31 32 33 |
# File 'lib/hydra/derivatives/processor.rb', line 31 def source_file object.attached_files[source_name.to_s] end |