Class: Makimono::Generator
- Inherits:
-
Object
- Object
- Makimono::Generator
- 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
-
#generator ⇒ Object
readonly
Returns the value of attribute generator.
Class Method Summary collapse
Instance Method Summary collapse
- #generate(documents) ⇒ Object
-
#initialize(generator) ⇒ Generator
constructor
A new instance of Generator.
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
#generator ⇒ Object (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 |