Class: TaskJuggler::ReportContext
- Defined in:
- lib/taskjuggler/reports/ReportContext.rb
Overview
The ReportContext objects provide some settings that are used during the generation of a report. Reports can be nested, so multiple objects can exist at a time. But there is only one current ReportContext that is always accessable via Project.reportContexts.last().
Instance Attribute Summary collapse
-
#attributeBackup ⇒ Object
Returns the value of attribute attributeBackup.
-
#childReportCounter ⇒ Object
Returns the value of attribute childReportCounter.
-
#dynamicReportId ⇒ Object
readonly
Returns the value of attribute dynamicReportId.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
-
#report ⇒ Object
readonly
Returns the value of attribute report.
-
#resources ⇒ Object
Returns the value of attribute resources.
-
#tasks ⇒ Object
Returns the value of attribute tasks.
Instance Method Summary collapse
-
#initialize(project, report) ⇒ ReportContext
constructor
A new instance of ReportContext.
Constructor Details
#initialize(project, report) ⇒ ReportContext
26 27 28 29 30 31 32 33 34 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 |
# File 'lib/taskjuggler/reports/ReportContext.rb', line 26 def initialize(project, report) @project = project @report = report @childReportCounter = 0 @attributeBackup = nil queryAttrs = { 'project' => @project, 'loadUnit' => @report.get('loadUnit'), 'numberFormat' => @report.get('numberFormat'), 'timeFormat' => @report.get('timeFormat'), 'currencyFormat' => @report.get('currencyFormat'), 'start' => @report.get('start'), 'end' => @report.get('end'), 'hideJournalEntry' => @report.get('hideJournalEntry'), 'journalMode' => @report.get('journalMode'), 'journalAttributes' => @report.get('journalAttributes'), 'sortJournalEntries' => @report.get('sortJournalEntries'), 'costAccount' => @report.get('costaccount'), 'revenueAccount' => @report.get('revenueaccount') } @query = Query.new(queryAttrs) if (@parent = @project.reportContexts.last) # For interactive reports we need some ID that uniquely identifies the # report within the composed report. Since a project report can be # included multiple times in the same report, we need to generate # another ID for each instantiated report. We create this report by # using a counter for the number of child reports that each report # has. The unique ID is then the concatenated list of counters from # parent to leaf, separating each value by a '.'. @dynamicReportId = @parent.dynamicReportId + ".#{@parent.childReportCounter}" @parent.childReportCounter += 1 # If the new ReportContext is created from within an existing context, # this is used as parent context and the settings are copied as # default initial values. @tasks = @parent.tasks.dup @resources = @parent.resources.dup else # The ID of the root report is always "0". The first child will then # be "0.0", the seconds "0.1" and so on. @dynamicReportId = "0" # There is no existing ReportContext yet, so we create one based on # the settings of the report. @tasks = @project.tasks.dup @resources = @project.resources.dup end end |
Instance Attribute Details
#attributeBackup ⇒ Object
Returns the value of attribute attributeBackup.
24 25 26 |
# File 'lib/taskjuggler/reports/ReportContext.rb', line 24 def attributeBackup @attributeBackup end |
#childReportCounter ⇒ Object
Returns the value of attribute childReportCounter.
24 25 26 |
# File 'lib/taskjuggler/reports/ReportContext.rb', line 24 def childReportCounter @childReportCounter end |
#dynamicReportId ⇒ Object (readonly)
Returns the value of attribute dynamicReportId.
23 24 25 |
# File 'lib/taskjuggler/reports/ReportContext.rb', line 23 def dynamicReportId @dynamicReportId end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
23 24 25 |
# File 'lib/taskjuggler/reports/ReportContext.rb', line 23 def project @project end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
23 24 25 |
# File 'lib/taskjuggler/reports/ReportContext.rb', line 23 def query @query end |
#report ⇒ Object (readonly)
Returns the value of attribute report.
23 24 25 |
# File 'lib/taskjuggler/reports/ReportContext.rb', line 23 def report @report end |
#resources ⇒ Object
Returns the value of attribute resources.
24 25 26 |
# File 'lib/taskjuggler/reports/ReportContext.rb', line 24 def resources @resources end |
#tasks ⇒ Object
Returns the value of attribute tasks.
24 25 26 |
# File 'lib/taskjuggler/reports/ReportContext.rb', line 24 def tasks @tasks end |