Class: Hydra::Derivatives::Processor

Inherits:
Object
  • Object
show all
Defined in:
lib/hydra/derivatives/processor.rb

Direct Known Subclasses

Audio, Document, Image, Jpeg2kImage, Video::Processor

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(obj, source_name, directives, opts = {}) ⇒ Processor



6
7
8
9
10
11
12
# File 'lib/hydra/derivatives/processor.rb', line 6

def initialize(obj, source_name, directives, opts={})
  self.object = obj
  self.source_name = source_name
  self.directives = directives
  self.source_file_service = opts.fetch(:source_file_service, Hydra::Derivatives.source_file_service)
  self.output_file_service = opts.fetch(:output_file_service, Hydra::Derivatives.output_file_service)
end

Instance Attribute Details

#directivesObject

Returns the value of attribute directives.



4
5
6
# File 'lib/hydra/derivatives/processor.rb', line 4

def directives
  @directives
end

#objectObject

Returns the value of attribute object.



4
5
6
# File 'lib/hydra/derivatives/processor.rb', line 4

def object
  @object
end

#output_file_serviceObject

Returns the value of attribute output_file_service.



4
5
6
# File 'lib/hydra/derivatives/processor.rb', line 4

def output_file_service
  @output_file_service
end

#source_file_serviceObject

Returns the value of attribute source_file_service.



4
5
6
# File 'lib/hydra/derivatives/processor.rb', line 4

def source_file_service
  @source_file_service
end

#source_nameObject

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_fileObject

Deprecated.

Please use a PersistOutputFileService class to save an object

Raises:

  • (NotImplementedError)


23
24
25
# File 'lib/hydra/derivatives/processor.rb', line 23

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



18
19
20
# File 'lib/hydra/derivatives/processor.rb', line 18

def output_file_id(name)
  [source_name, name].join('_')
end

#processObject



14
15
16
# File 'lib/hydra/derivatives/processor.rb', line 14

def process
  raise "Processor is an abstract class. Implement `process' on #{self.class.name}"
end

#source_fileObject



27
28
29
# File 'lib/hydra/derivatives/processor.rb', line 27

def source_file
  @source_file ||= source_file_service.call(object, source_name)
end