Class: Makimono::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/makimono/generator.rb,
lib/makimono/generator/epub.rb,
lib/makimono/generator/simple_file.rb

Defined Under Namespace

Classes: Epub, SimpleFile

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(generator) ⇒ Generator

Returns a new instance of Generator.



23
24
25
# File 'lib/makimono/generator.rb', line 23

def initialize(generator)
  @generator = generator
end

Instance Attribute Details

#generatorObject (readonly)

Returns the value of attribute generator.



21
22
23
# File 'lib/makimono/generator.rb', line 21

def generator
  @generator
end

Class Method Details

.from_config(config) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/makimono/generator.rb', line 8

def self.from_config(config)
  klass = if config[:generator].upcase == 'EPUB'
            Epub
          elsif config[:generator] == 'SimpleFile'
            SimpleFile
          else
            const_get(config[:generator].to_s)
          end
  new(klass.new(config))
rescue NameError
  raise InvalidGeneratorError, "Invalid generator configuration: #{config[:generator]}"
end

Instance Method Details

#generate(documents) ⇒ Object



27
28
29
# File 'lib/makimono/generator.rb', line 27

def generate(documents)
  generator.generate(documents)
end