Parent

Class Index [+]

Quicksearch

TaskJuggler::NavigatorElement

Attributes

parent[R]
label[R]
url[RW]
elements[RW]
current[RW]

Public Class Methods

new(parent, label = nil, url = nil) click to toggle source
    # File lib/taskjuggler/reports/Navigator.rb, line 23
23:     def initialize(parent, label = nil, url = nil)
24:       @parent = parent
25:       @label = label
26:       @url = url
27:       @elements = []
28:       # True if the current report is included in this NavigatorElement or any
29:       # of its sub elements.
30:       @current = false
31:     end

Public Instance Methods

currentUrl() click to toggle source

Get the URL of the current report from the root node.

    # File lib/taskjuggler/reports/Navigator.rb, line 96
96:     def currentUrl
97:       root.url
98:     end
currentUrl=(url) click to toggle source

Store the URL for the current report. Since the URL entry in the root node of the NavigatorElement tree is never used, we use it to store the current URL there.

    # File lib/taskjuggler/reports/Navigator.rb, line 91
91:     def currentUrl=(url)
92:       root.url = url
93:     end
root() click to toggle source

Traverse the tree all the way to the top and return the root element.

     # File lib/taskjuggler/reports/Navigator.rb, line 101
101:     def root
102:       p = self
103:       while p.parent
104:         p = p.parent
105:       end
106:       p
107:     end
to_html() click to toggle source
    # File lib/taskjuggler/reports/Navigator.rb, line 33
33:     def to_html
34:       first = true
35:       html = (div = XMLElement.new('div'))
36: 
37:       @elements.each do |element|
38:         next unless label
39: 
40:         if first
41:           first = false
42:         else
43:           div << XMLText.new('|')
44:         end
45: 
46:         url = element.url
47:         if !url
48:           nEl = element
49:           while nEl.elements[0]
50:             break if nEl.current
51: 
52:             if nEl.elements[0].url
53:               url = nEl.elements[0].url
54:               break
55:             end
56:             nEl = nEl.elements[0]
57:           end
58:         end
59:         if url && url != currentUrl
60:           div << (span = XMLElement.new('span', 'class' => 'navbar_other'))
61:           span << (a = XMLElement.new('a', 'href' => url))
62:           a << XMLText.new(element.label)
63:         else
64:           div << (span = XMLElement.new('span',
65:                                         'class' => 'navbar_current'))
66:           span << XMLText.new(element.label)
67:         end
68:       end
69:       @elements.each do |element|
70:         if element.current && !element.elements.empty?
71:           html << XMLElement.new('hr', {}, true) unless first
72:           html << element.to_html
73:         end
74:       end
75:       html
76:     end
to_s(indent = 0) click to toggle source

Return a text version of the tree. Currently used for debugging only.

    # File lib/taskjuggler/reports/Navigator.rb, line 79
79:     def to_s(indent = 0)
80:       @elements.each do |element|
81:         puts "#{' ' * indent}#{element.current ? '<' : ''}" +
82:              "#{element.label}#{element.current ? '>' : ''}" +
83:              " -> #{element.url}"
84:         element.to_s(indent + 1)
85:       end
86:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.