Class: CbrToEpub::Output::EpubBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/cbr_to_epub/output/epub_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(file_manager, data) ⇒ EpubBuilder

Returns a new instance of EpubBuilder.



7
8
9
10
# File 'lib/cbr_to_epub/output/epub_builder.rb', line 7

def initialize(file_manager, data)
  @file_manager = file_manager
  @data = data
end

Instance Method Details

#generate_imagesObject



29
30
31
32
33
# File 'lib/cbr_to_epub/output/epub_builder.rb', line 29

def generate_images
  data.pages.each do |page|
    FileUtils.copy(page.input_image_file, File.join(output_directory, 'OEBPS/', page.image_file))
  end
end

#generate_metadataObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/cbr_to_epub/output/epub_builder.rb', line 12

def 
  Dir.mkdir(File.join(output_directory, 'META-INF'))
  Dir.mkdir(File.join(output_directory, 'OEBPS'))

  copy_template('mimetype')
  copy_template('META-INF/container.xml')
  copy_template('OEBPS/style.css')
  render_template('OEBPS/content.opf', data)
  render_template('OEBPS/toc.ncx', data)
end

#generate_pagesObject



23
24
25
26
27
# File 'lib/cbr_to_epub/output/epub_builder.rb', line 23

def generate_pages
  data.pages.each do |page|
    render_template('OEBPS/page.xhtml', page, output_file_name = File.join('OEBPS', page.page_file))
  end
end