Class: Maliq::Epub
- Inherits:
-
Object
- Object
- Maliq::Epub
- Defined in:
- lib/maliq/epub.rb
Instance Method Summary collapse
- #create! ⇒ Object
-
#initialize(opts) ⇒ Epub
constructor
A new instance of Epub.
Constructor Details
#initialize(opts) ⇒ Epub
Returns a new instance of Epub.
5 6 7 8 9 10 11 |
# File 'lib/maliq/epub.rb', line 5 def initialize(opts) @opts = opts @output = @opts.delete(:output) || 'out.epub' @path = opts[:path] || '.' set_files_by_type(@path) @metadata = end |
Instance Method Details
#create! ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/maliq/epub.rb', line 13 def create! # Instance variables need to be locals, because a block of, # GEPUB::Builder.new changes its context with instance_eval. = @metadata csses = @csses cover_img = @cover_image images = @images cover_xhtml = @cover_xhtml navfile = @navfile heading_files = @heading_files xhtmls = @xhtmls path = @path GEPUB::Builder.new do .each { |k, *v| send k, *v } resources(:workdir => path) { csses.each { |f| file f } cover_image cover_img if cover_img images.each { |f| file(f) } ordered { if cover_xhtml file 'cover.xhtml' => cover_xhtml heading 'Cover' end nav navfile if navfile xhtmls.each do |fname, head| file fname heading head if !navfile || heading_files.include?(fname) end } } end.generate_epub(@output) end |