This class can be used to store a table of contents. It’s just an Array of TOCEntry objects. Each TOCEntry objects represents the title of a section.
Create an empty TableOfContents object.
# File lib/TableOfContents.rb, line 23 23: def initialize 24: @entries = [] 25: end
This method must be used to add new TOCEntry objects to the TableOfContents. entry must be a TOCEntry object reference.
# File lib/TableOfContents.rb, line 29 29: def addEntry(entry) 30: @entries << entry 31: end
# File lib/TableOfContents.rb, line 33 33: def each 34: @entries.each { |e| yield e } 35: end
Return HTML elements that represent the content of the TableOfContents object. The result is a tree of XMLElement objects.
# File lib/TableOfContents.rb, line 39 39: def to_html 40: div = XMLElement.new('div', 'style' => 'margin-left:15%; margin-right:15%;') 41: div << (table = XMLElement.new('table')) 42: @entries.each { |e| table << e.to_html } 43: 44: div 45: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.