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/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

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/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

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/taskjuggler/RichText/TOCEntry.rb, line 70
70:     def level
71:       lev = 0
72:       @number.each_utf8_char { |c| lev += 1 if c == '.' }
73:       lev
74:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.