In Files

Parent

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.

Attributes

number[R]
title[R]
tag[R]

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

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 69
69:     def level
70:       lev = 0
71:       @number.each_utf8_char { |c| lev += 1 if c == '.' }
72:       lev
73:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.