Sha256: f21dd5b84b143650521f3dd2076d2e17887d3d6c4dbac30e58c9367b11d47de2

Contents?: true

Size: 864 Bytes

Versions: 2

Compression:

Stored size: 864 Bytes

Contents

require 'epub/ocf'
require 'epub/publication'
require 'epub/content_document'

module EPUB
  modules = [ :ocf, :package, :content_document ]
  attr_reader *modules
  modules.each do |mod|
    define_method "#{mod}=" do |obj|
      instance_variable_set "@#{mod}", obj
      obj.book = self
    end
  end

  def each_page_by_spine(&blk)
    enum = @package.spine.items
    if block_given?
      enum.each &blk
    else
      enum
    end
  end

  def each_page_by_toc(&blk)
  end

  def each_content(&blk)
    enum = @package.manifest.items
    if block_given?
      enum.each &blk
    else
      enum.to_enum
    end
  end

  def other_navigation
  end

  def resources
    @package.manifest.items
  end

  # Syntax sugar
  def rootfile_path
    ocf.container.rootfile.full_path
  end

  # Syntax sugar
  def cover_image
    package.manifest.cover_image
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
epub-parser-0.0.5 lib/epub.rb
epub-parser-0.0.4 lib/epub.rb