Class: Epubber::Generators::Cover

Inherits:
Epubber::Generator show all
Defined in:
lib/epubber/generators/cover.rb

Instance Attribute Summary

Attributes inherited from Epubber::Generator

#book, #filename, #working_dir

Instance Method Summary collapse

Methods inherited from Epubber::Generator

#initialize, #register_generators

Constructor Details

This class inherits a constructor from Epubber::Generator

Instance Method Details

#generateObject



5
6
7
8
9
10
11
12
13
# File 'lib/epubber/generators/cover.rb', line 5

def generate
  # Because this is an optional generator, don't do anything if there's no
  # introduction in the book
  return if book.cover.nil?

  content = template.parse file: 'OEBPS/Text/cover.xhtml', context: book_context
  persist file: 'OEBPS/Text/cover.xhtml', content: content
  persist file: "OEBPS/Images/#{book_context['book']['cover']['filename']}", content: book_context['book']['cover']['file']
end