Class: EPUB::ContentDocument::Navigation

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

Defined Under Namespace

Modules: Hidable Classes: Item, ItemList, Navigation

Instance Attribute Summary collapse

Attributes inherited from XHTML

#item

Instance Method Summary collapse

Methods inherited from XHTML

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

Constructor Details

#initializeNavigation

Returns a new instance of Navigation



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

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

Instance Attribute Details

Returns the value of attribute navigations



6
7
8
# File 'lib/epub/content_document/navigation.rb', line 6

def navigations
  @navigations
end

Instance Method Details

#contentsObject

Enumerator version of toc



28
29
30
# File 'lib/epub/content_document/navigation.rb', line 28

def contents
  enum_for(:each_content).to_a
end

#each_contentObject

iterator for #toc



41
42
43
44
45
# File 'lib/epub/content_document/navigation.rb', line 41

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

#each_landmarkObject

iterator for #landmark

Raises:

  • (NotImplementedError)


53
54
55
# File 'lib/epub/content_document/navigation.rb', line 53

def each_landmark
  raise NotImplementedError
end

#each_pageObject

iterator for #page_list

Raises:

  • (NotImplementedError)


48
49
50
# File 'lib/epub/content_document/navigation.rb', line 48

def each_page
  raise NotImplementedError
end

#landmarksObject



23
24
25
# File 'lib/epub/content_document/navigation.rb', line 23

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


57
58
59
# File 'lib/epub/content_document/navigation.rb', line 57

def navigation
  navigations.first
end

#page_listObject



19
20
21
# File 'lib/epub/content_document/navigation.rb', line 19

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

#pagesObject

Enumerator version of page_list

Usage: navigation.enum_for(:pages)

Raises:

  • (NotImplementedError)


34
35
36
# File 'lib/epub/content_document/navigation.rb', line 34

def pages
  raise NotImplementedError
end

#tocObject



15
16
17
# File 'lib/epub/content_document/navigation.rb', line 15

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