Class: TaskJuggler::RTFReport

Inherits:
RichTextFunctionHandler show all
Defined in:
lib/taskjuggler/RichText/RTFReport.rb

Overview

This class is a specialized RichTextFunctionHandler that includes a report into the RichText output for supported formats.

Instance Attribute Summary

Attributes inherited from RichTextFunctionHandler

#blockFunction, #function

Instance Method Summary collapse

Methods included from MessageHandler

#critical, #debug, #error, #fatal, #info, #warning

Constructor Details

#initialize(project, sourceFileInfo = nil) ⇒ RTFReport

Returns a new instance of RTFReport.



23
24
25
26
27
# File 'lib/taskjuggler/RichText/RTFReport.rb', line 23

def initialize(project, sourceFileInfo = nil)
  @project = project
  super('report', sourceFileInfo)
  @blockFunction = true
end

Instance Method Details

#to_html(args) ⇒ Object

Return a HTML tree for the report.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/taskjuggler/RichText/RTFReport.rb', line 35

def to_html(args)
  if args.nil? || (id = args['id']).nil?
    error('rtp_report_id',
          "Argument 'id' missing to specify the report to be used.")
    return nil
  end
  unless (report = @project.report(id))
    error('rtp_report_unknown_id', "Unknown report #{id}")
    return nil
  end
  # Detect recursive nesting
  found = false
  @project.reportContexts.each do |c|
    if c.report == report
      found = true
      break
    end
  end
  if found
    stack = ""
    @project.reportContexts.each do |context|
      stack += ' -> ' unless stack.empty?
      stack += '[ ' if context.report == report
      stack += context.report.fullId
    end
    stack += " -> #{report.fullId} ] ..."
    error('rtp_report_recursion',
          "Recursive nesting of reports detected: #{stack}")
    return nil
  end

  # Create a new context for the report.
  @project.reportContexts.push(ReportContext.new(@project, report))
  # Generate the report with the new context
  report.generateIntermediateFormat
  html = report.to_html
  @project.reportContexts.pop

  html
end

#to_s(args) ⇒ Object

Not supported for this function



30
31
32
# File 'lib/taskjuggler/RichText/RTFReport.rb', line 30

def to_s(args)
  ''
end

#to_tagged(args) ⇒ Object

Not supported for this function.



77
78
79
# File 'lib/taskjuggler/RichText/RTFReport.rb', line 77

def to_tagged(args)
  nil
end