Class: Makimono::Generator::Epub

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

Instance Method Summary collapse

Constructor Details

#initialize(config, book: GEPUB::Book.new) ⇒ Epub

Returns a new instance of Epub.



9
10
11
12
# File 'lib/makimono/generator/epub.rb', line 9

def initialize(config, book: GEPUB::Book.new)
  @config = config
  @book = book
end

Instance Method Details

#generate(resources) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/makimono/generator/epub.rb', line 14

def generate(resources)
  
  
  @book.page_progression_direction = @config[:page_progression_direction] if @config[:page_progression_direction]

  add_items([@config.style, *resources.reject(&:ordered?)].compact)
  add_ordered_items(resources.select(&:ordered?).sort_by(&:number))

  FileUtils.mkdir_p(@config[:output]) unless Dir.exist?(@config[:output])
  @book.generate_epub("#{File.expand_path(@config[:ebook_file_name], @config[:output])}.epub")
end