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/TOCEntry.rb, line 31 31: def initialize(number, title, file, tag = nil) 32: @number = number 33: @title = title 34: @file = file 35: @tag = tag 36: end
Return the TOCEntry as equivalent HTML elements. The result is an Array of XMLElement objects.
# File lib/TOCEntry.rb, line 40 40: def to_html 41: html = [] 42: 43: if level == 0 44: # A another table line for some extra distance above main chapters. 45: html << (tr = XMLElement.new('tr')) 46: tr << (td = XMLElement.new('td')) 47: td << XMLElement.new('div', 'style' => 'height:10px') 48: end 49: 50: fontSizes = [ 20, 17, 15 ] 51: tr = XMLElement.new('tr', 'style' => "font-size:#{fontSizes[level]}px;") 52: tr << (td = XMLElement.new('td', 53: 'style' => "padding-left:#{10 * level}px")) 54: td << XMLText.new(@number) 55: tr << (td = XMLElement.new('td', 56: 'style' => "padding-left:#{5 + 20 * level}px")) 57: tag = @tag ? "##{@tag}" : '' 58: td << (a = XMLElement.new('a', 'href' => "#{@file}.html#{tag}")) 59: a << XMLText.new(@title) 60: html << tr 61: 62: html 63: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.