Sha256: 4bd0c45e98afc93b2697589e91e8f8264c2768e0bcf5384096ca0c45e214bab5

Contents?: true

Size: 1.47 KB

Versions: 1

Compression:

Stored size: 1.47 KB

Contents

require 'epub/content_document/xhtml'

module EPUB
  module ContentDocument
    class Navigation < XHTML
      attr_accessor :navigations

      def initialize
        @navigations = []
        super
      end

      def toc
        items.selector {|nav| nav.type == Navigation::Type::TOC}.first
      end

      def page_list
        items.selector {|nav| nav.type == Nagivation::Type::PAGE_LIST}.first
      end

      def landmarks
        items.selector {|nav| nav.type == Navigation::Type::LANDMARKS}.first
      end

      # Enumerator version of toc
      #  Usage: nagivation.enum_for(:contents)
      def contents
      end

      # Enumerator version of page_list
      #  Usage: navigation.enum_for(:pages)
      def pages
      end

      # iterator for #toc
      def each_content
      end

      # iterator for #page_list
      def each_page
      end

      # iterator for #landmark
      def each_landmark
      end

      class Item
        attr_accessor :items, :text, :hidden,
                      :content_document, :href, :item

        def initialize
          @items = []
        end

        def hidden?
          !! hidden
        end
      end

      class Navigation < Item
        module Type
          TOC       = 'toc'
          PAGE_LIST = 'page_list'
          LANDMARKS = 'landmarks'
        end

        attr_accessor :type
        alias navigations items
        alias navigations= items=
        alias heading text
        alias heading= text=
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
epub-parser-0.1.3 lib/epub/content_document/navigation.rb