Class: Hydra::Derivatives::Processors::Processor

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

Overview

Processors take a single input and produce a single output

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Processor.

Parameters:

  • source_path (String)

    path to the file on disk

  • directives (Hash)

    directions for creating the output

  • opts (Hash) (defaults to: {})
  • [String] (Hash)

    a customizable set of options

  • [#call] (Hash)

    a customizable set of options



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

def initialize(source_path, directives, opts = {})
  self.source_path = source_path
  self.directives = directives
  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.



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

def directives
  @directives
end

#output_file_serviceObject

Returns the value of attribute output_file_service.



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

def output_file_service
  @output_file_service
end

#source_pathObject

Returns the value of attribute source_path.



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

def source_path
  @source_path
end

Instance Method Details

#output_fileObject

Deprecated.

Please use a PersistOutputFileService class to save an object

Raises:

  • (NotImplementedError)


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

def output_file
  raise NotImplementedError, "Processor is an abstract class. Utilize an implementation of a PersistOutputFileService class in #{self.class.name}"
end

#output_filename_for(_name) ⇒ Object



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

def output_filename_for(_name)
  File.basename(source_path)
end

#processObject



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

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