Sha256: 79ec644f1ff70e7182e32b3507068c8d6e04a35cf4f79e4e2bffad137612fa86

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

module Rpub
  class Epub
    class Toc < XmlFile
      attr_reader :book

      def initialize(book)
        @book = book
        super()
      end

      def render
        xml.instruct!
        xml.declare! :DOCTYPE, :ncx, :PUBLIC, "-//W3C//DTD XHTML 1.1//EN", 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'
        xml.ncx :xmlns => 'http://www.daisy.org/z3986/2005/ncx/', :version => '2005-1' do
          xml.head do
            xml.meta :name => 'dtb:uid', :content => book.uid
            xml.meta :name => 'dtb:depth', :content => '1'
            xml.meta :name => 'dtb:totalPageCount', :content => '0'
            xml.meta :name => 'dtb:maxPageNumber', :content => '0'
          end
          xml.docTitle { xml.text book.title }
          xml.navMap do
            book.chapters.each_with_index do |chapter, n|
              xml.navPoint :id => chapter.xml_id, :playOrder => n do
                xml.navLabel { xml.text chapter.title }
                xml.content :src => chapter.filename
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rpub-0.3.0 lib/rpub/epub/toc.rb
rpub-0.2.1 lib/rpub/epub/toc.rb