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) ⇒ 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

#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

#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_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

#processObject



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_fileObject



31
32
33
# File 'lib/hydra/derivatives/processor.rb', line 31

def source_file
  object.attached_files[source_name.to_s]
end