Parent

Files

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/reports/Navigator.rb, line 22
22:     def initialize(parent, label = nil, url = nil)
23:       @parent = parent
24:       @label = label
25:       @url = url
26:       @elements = []
27:       # True if the current report is included in this NavigatorElement or any
28:       # of its sub elements.
29:       @current = false
30:     end

Public Instance Methods

currentUrl() click to toggle source

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

    # File lib/reports/Navigator.rb, line 95
95:     def currentUrl
96:       root.url
97:     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/reports/Navigator.rb, line 90
90:     def currentUrl=(url)
91:       root.url = url
92:     end
root() click to toggle source

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

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

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

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

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.