Class: Navigation

Inherits:
Object
  • Object
show all
Defined in:
lib/epubinfo/models/table_of_contents/navigation.rb

Instance Method Summary collapse

Constructor Details

#initialize(table_of_contents) ⇒ Navigation

Returns a new instance of Navigation.



2
3
4
# File 'lib/epubinfo/models/table_of_contents/navigation.rb', line 2

def initialize(table_of_contents)
  @table_of_contents = table_of_contents
end

Instance Method Details



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/epubinfo/models/table_of_contents/navigation.rb', line 10

def nav_map
  ncx_doc = Nokogiri::XML(@table_of_contents.parser.zip_file.read(path))
  ncx_doc.remove_namespaces!

  if ncx_doc
    #map = ncx_doc.xpath('//navMap/navPoint').map do |navpoint|
    map = ncx_doc.xpath('//navPoint').map do |navpoint|
      {'label' =>(navpoint % 'navLabel/text').content , 'path' => (navpoint % 'content').attr('src')}
    end
  end

end

#pathObject



6
7
8
# File 'lib/epubinfo/models/table_of_contents/navigation.rb', line 6

def path
  @table_of_contents.path
end