Class: EpubTools::EpubInitializer

Inherits:
Object
  • Object
show all
Defined in:
lib/epub_tools/epub_initializer.rb

Instance Method Summary collapse

Constructor Details

#initialize(title, author, destination, cover_image = nil) ⇒ EpubInitializer

title: book title; author: author name; destination: output EPUB directory cover_image: optional path to cover image file



10
11
12
13
14
15
16
17
18
19
# File 'lib/epub_tools/epub_initializer.rb', line 10

def initialize(title, author, destination, cover_image = nil)
  @title = title
  @author = author
  @destination = File.expand_path(destination)
  @uuid = "urn:uuid:#{SecureRandom.uuid}"
  @modified = Time.now.utc.iso8601
  @cover_image_path = cover_image
  @cover_image_fname = nil
  @cover_image_media_type = nil
end

Instance Method Details

#runObject



21
22
23
24
25
26
27
28
29
30
# File 'lib/epub_tools/epub_initializer.rb', line 21

def run
  create_structure
  write_mimetype
  write_title_page
  write_container
  write_cover if @cover_image_path
  write_package_opf
  write_nav
  write_style
end