A TOCEntry object is used to store the data of an entry in a TableOfContents object. It stores the section number, the title, the file name and the name of the tag in this file. The tag is optional and may be nil. The object can be turned into an HTML tree.
Create a TOCEntry object. number: The section number as String, e. g. ‘1.2.3’ or ‘A.3’. title: The section title as String. file: The name of the file. tag: An optional tag within the file.
# File lib/taskjuggler/RichText/TOCEntry.rb, line 32 32: def initialize(number, title, file, tag = nil) 33: @number = number 34: @title = title 35: @file = file 36: @tag = tag 37: end
Return the TOCEntry as equivalent HTML elements. The result is an Array of XMLElement objects.
# File lib/taskjuggler/RichText/TOCEntry.rb, line 41 41: def to_html 42: html = [] 43: 44: if level == 0 45: # A another table line for some extra distance above main chapters. 46: html << (tr = XMLElement.new('tr')) 47: tr << (td = XMLElement.new('td')) 48: td << XMLElement.new('div', 'style' => 'height:10px') 49: end 50: 51: fontSizes = [ 20, 17, 15 ] 52: tr = XMLElement.new('tr', 'style' => "font-size:#{fontSizes[level]}px;") 53: tr << (td = XMLElement.new('td', 54: 'style' => "padding-left:#{10 * level}px")) 55: td << XMLText.new(@number) 56: tr << (td = XMLElement.new('td', 57: 'style' => "padding-left:#{5 + 20 * level}px")) 58: tag = @tag ? "##{@tag}" : '' 59: td << (a = XMLElement.new('a', 'href' => "#{@file}.html#{tag}")) 60: a << XMLText.new(@title) 61: html << tr 62: 63: html 64: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.