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
# File 'lib/epub/content_document/navigation.rb', line 6

def initialize
  @navigations = []
  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


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

def contents
  enum_for(:each_content).to_a
end

#each_contentObject

iterator for #toc


37
38
39
40
41
# File 'lib/epub/content_document/navigation.rb', line 37

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

#each_landmarkObject

iterator for #landmark

Raises:

  • (NotImplementedError)

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

def each_landmark
  raise NotImplementedError
end

#each_pageObject

iterator for #page_list

Raises:

  • (NotImplementedError)

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

def each_page
  raise NotImplementedError
end

#landmarksObject


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

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

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

def navigation
  navigations.first
end

#page_listObject


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

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

#pagesObject

Enumerator version of page_list

Usage: navigation.enum_for(:pages)

Raises:

  • (NotImplementedError)

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

def pages
  raise NotImplementedError
end

#tocObject


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

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