class 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/taskjuggler/RichText/TOCEntry.rb, line 32
def initialize(number, title, file, tag = nil)
  @number = number
  @title = title
  @file = file
  @tag = tag

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
def to_html
  html = []

  if level == 0
    # A another table line for some extra distance above main chapters.
    html << (tr ='tr'))
    tr << (td ='td'))
    td <<'div', 'style' => 'height:10px')

  # Use a different font size depending on the element level.
  fontSizes = [ 20, 17, 15, 14, 14 ]

  tr ='tr', 'style' => "font-size:#{fontSizes[level]}px;")
  tr << (td ='td', 'style' => "width:30px;"))
  # Top-level headings have their number in the left column.
  td << if level == 0

  tr << (td ='td'))
  if level > 0
    # Lower level headings have their number in the right column with the
    # heading text.
    td <<'span', 'style' => 'padding-right:15px') do
  tag = @tag ? "##{@tag}" : ''
  td << (a ='a', 'href' => "#{@file}.html#{tag}"))
  a <<
  html << tr