In Files

Parent

Files

Class Index [+]

Quicksearch

TaskJuggler::TOCEntry

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.

Public Class Methods

new(number, title, file, tag = nil) click to toggle source

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 29
29:     def initialize(number, title, file, tag = nil)
30:       @number = number
31:       @title = title
32:       @file = file
33:       @tag = tag
34:     end

Public Instance Methods

to_html() click to toggle source

Return the TOCEntry as equivalent HTML elements. The result is an Array of XMLElement objects.

    # File lib/TOCEntry.rb, line 38
38:     def to_html
39:       html = []
40: 
41:       if level == 0
42:         # A another table line for some extra distance above main chapters.
43:         html << (tr = XMLElement.new('tr'))
44:         tr << (td = XMLElement.new('td'))
45:         td << XMLElement.new('div', 'style' => 'height:10px')
46:       end
47: 
48:       fontSizes = [ 20, 17, 15 ]
49:       tr = XMLElement.new('tr', 'style' => "font-size:#{fontSizes[level]}px;")
50:       tr << (td = XMLElement.new('td',
51:                                  'style' => "padding-left:#{10 * level}px"))
52:       td << XMLText.new(@number)
53:       tr << (td = XMLElement.new('td',
54:                                  'style' => "padding-left:#{5 + 20 * level}px"))
55:       tag = @tag ? "##{@tag}" : ''
56:       td << (a = XMLElement.new('a', 'href' => "#{@file}.html#{tag}"))
57:       a << XMLText.new(@title)
58:       html << tr
59: 
60:       html
61:     end

Private Instance Methods

level() click to toggle source

Returns the level of the section. It simply counts the number of dots in the section number.

    # File lib/TOCEntry.rb, line 67
67:     def level
68:       lev = 0
69:       @number.each_utf8_char { |c| lev += 1 if c == '.' }
70:       lev
71:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.