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.



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

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

Instance Attribute Details

Returns the value of attribute navigations.



4
5
6
# File 'lib/epub/content_document/navigation.rb', line 4

def navigations
  @navigations
end

Instance Method Details

#contentsObject

Enumerator version of toc



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

def contents
  enum_for(:each_content).to_a
end

#each_contentObject

iterator for #toc



39
40
41
42
43
# File 'lib/epub/content_document/navigation.rb', line 39

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

#each_landmarkObject

iterator for #landmark

Raises:

  • (NotImplementedError)


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

def each_landmark
  raise NotImplementedError
end

#each_pageObject

iterator for #page_list

Raises:

  • (NotImplementedError)


46
47
48
# File 'lib/epub/content_document/navigation.rb', line 46

def each_page
  raise NotImplementedError
end

#landmarksObject



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

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


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

def navigation
  navigations.first
end

#page_listObject



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

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

#pagesObject

Enumerator version of page_list

Usage: navigation.enum_for(:pages)

Raises:

  • (NotImplementedError)


32
33
34
# File 'lib/epub/content_document/navigation.rb', line 32

def pages
  raise NotImplementedError
end

#tocObject



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

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