Sha256: 0b145a864c81558e3f183edfb15ea4c0e208b9d586d08d87b1407614dfa3f4e8

Contents?: true

Size: 899 Bytes

Versions: 3

Compression:

Stored size: 899 Bytes

Contents

module Hydra
  module Derivatives
    class Processor
      attr_accessor :object, :source_name, :directives

      def initialize(obj, source_name, directives)
        self.object = obj
        self.source_name = source_name
        self.directives = directives
      end

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

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

      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

      def source_file
        object.attached_files[source_name.to_s]
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hydra-derivatives-1.0.0 lib/hydra/derivatives/processor.rb
hydra-derivatives-1.0.0.rc1 lib/hydra/derivatives/processor.rb
hydra-derivatives-1.0.0.beta1 lib/hydra/derivatives/processor.rb