Class: EPUB::ContentDocument::Navigation

Inherits:
XHTML
  • Object
show all
Includes:
Typable
Defined in:
lib/epub/content_document/navigation.rb

Defined Under Namespace

Modules: Hidable Classes: Item, ItemList, Navigation

Instance Attribute Summary collapse

Attributes included from Typable

#types

Attributes inherited from XHTML

#item

Instance Method Summary collapse

Methods inherited from XHTML

#nokogiri, #oga, #read, #rexml, #title, #top_level?

Constructor Details

#initializeNavigation

Returns a new instance of Navigation.



10
11
12
13
14
15
# File 'lib/epub/content_document/navigation.rb', line 10

def initialize
  @navigations = []
  @hidden = false
  @parent = nil
  super
end

Instance Attribute Details

Returns the value of attribute navigations.



8
9
10
# File 'lib/epub/content_document/navigation.rb', line 8

def navigations
  @navigations
end

Instance Method Details

#contentsObject

Enumerator version of toc



30
31
32
# File 'lib/epub/content_document/navigation.rb', line 30

def contents
  enum_for(:each_content).to_a
end

#each_contentObject

iterator for #toc



43
44
45
46
47
# File 'lib/epub/content_document/navigation.rb', line 43

def each_content
  toc.traverse do |content, _|
    yield content
  end
end

#each_landmarkObject

iterator for #landmark

Raises:

  • (NotImplementedError)


55
56
57
# File 'lib/epub/content_document/navigation.rb', line 55

def each_landmark
  raise NotImplementedError
end

#each_pageObject

iterator for #page_list

Raises:

  • (NotImplementedError)


50
51
52
# File 'lib/epub/content_document/navigation.rb', line 50

def each_page
  raise NotImplementedError
end

#landmarksObject



25
26
27
# File 'lib/epub/content_document/navigation.rb', line 25

def landmarks
  navigations.find(&:landmarks?)
end


59
60
61
# File 'lib/epub/content_document/navigation.rb', line 59

def navigation
  navigations.first
end

#page_listObject



21
22
23
# File 'lib/epub/content_document/navigation.rb', line 21

def page_list
  navigations.find(&:page_list?)
end

#pagesObject

Enumerator version of page_list

Usage: navigation.enum_for(:pages)

Raises:

  • (NotImplementedError)


36
37
38
# File 'lib/epub/content_document/navigation.rb', line 36

def pages
  raise NotImplementedError
end

#tocObject



17
18
19
# File 'lib/epub/content_document/navigation.rb', line 17

def toc
  navigations.find(&:toc?)
end