Class: Rpub::Epub::HtmlToc
Instance Attribute Summary collapse
-
#book ⇒ Object
readonly
Returns the value of attribute book.
Attributes inherited from XmlFile
Instance Method Summary collapse
-
#initialize(book) ⇒ HtmlToc
constructor
A new instance of HtmlToc.
- #render ⇒ Object
Methods inherited from XmlFile
Constructor Details
#initialize(book) ⇒ HtmlToc
Returns a new instance of HtmlToc.
6 7 8 9 |
# File 'lib/rpub/epub/html_toc.rb', line 6 def initialize(book) @book = book super() end |
Instance Attribute Details
#book ⇒ Object (readonly)
Returns the value of attribute book.
4 5 6 |
# File 'lib/rpub/epub/html_toc.rb', line 4 def book @book end |
Instance Method Details
#render ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rpub/epub/html_toc.rb', line 11 def render xml.div :id => 'toc' do xml.h1 'Table of Contents' xml.div :class => 'toc' do book.outline.each do |(filename, headings)| headings.each do |heading| xml.div :class => "level-#{heading.level}" do xml.a heading.text, :href => [filename, heading.html_id].join('#') end end end end end end |