Class: Ddr::Derivatives::Generator Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/ddr/derivatives/generator.rb

Overview

This class is abstract.

Direct Known Subclasses

PngGenerator, PtifGenerator

Defined Under Namespace

Classes: GeneratorResult

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, output, options = nil) ⇒ Generator

Returns a new instance of Generator.

Raises:

  • (ArgumentError)


10
11
12
13
14
15
16
# File 'lib/ddr/derivatives/generator.rb', line 10

def initialize source, output, options=nil
  raise ArgumentError, "Source must be a File or path to a file" unless Ddr::Utils.file_or_path?(source)
  raise ArgumentError, "Output must be a File or path to a file" unless Ddr::Utils.file_or_path?(output)
  @source = source
  @output = output
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/ddr/derivatives/generator.rb', line 6

def options
  @options
end

#outputObject (readonly)

Returns the value of attribute output.



6
7
8
# File 'lib/ddr/derivatives/generator.rb', line 6

def output
  @output
end

#sourceObject (readonly)

Returns the value of attribute source.



6
7
8
# File 'lib/ddr/derivatives/generator.rb', line 6

def source
  @source
end

Class Method Details

.output_mime_typeObject

The mime type of the output generated. Implemented in each subclass.

Raises:

  • (NotImplementedError)


20
21
22
# File 'lib/ddr/derivatives/generator.rb', line 20

def self.output_mime_type
  raise NotImplementedError
end

Instance Method Details

#generateObject

The actions required to generate the output from the source. Implemented in each subclass.

Raises:

  • (NotImplementedError)


26
27
28
# File 'lib/ddr/derivatives/generator.rb', line 26

def generate
  raise NotImplementedError
end