Class: TaskJuggler::TableOfContents

Inherits:
Object
  • Object
show all
Defined in:
lib/taskjuggler/RichText/TableOfContents.rb

Overview

This class can be used to store a table of contents. It’s just an Array of TOCEntry objects. Each TOCEntry objects represents the title of a section.

Instance Method Summary collapse

Constructor Details

#initializeTableOfContents

Create an empty TableOfContents object.



25
26
27
# File 'lib/taskjuggler/RichText/TableOfContents.rb', line 25

def initialize
  @entries = []
end

Instance Method Details

#addEntry(entry) ⇒ Object

This method must be used to add new TOCEntry objects to the TableOfContents. entry must be a TOCEntry object reference.



31
32
33
# File 'lib/taskjuggler/RichText/TableOfContents.rb', line 31

def addEntry(entry)
  @entries << entry
end

#eachObject



35
36
37
# File 'lib/taskjuggler/RichText/TableOfContents.rb', line 35

def each
  @entries.each { |e| yield e }
end

#to_htmlObject

Return HTML elements that represent the content of the TableOfContents object. The result is a tree of XMLElement objects.



41
42
43
44
45
46
47
48
# File 'lib/taskjuggler/RichText/TableOfContents.rb', line 41

def to_html
  div = XMLElement.new('div',
                       'style' => 'margin-left:15%; margin-right:15%;')
  div << (table = XMLElement.new('table'))
  @entries.each { |e| table << e.to_html }

  div
end