class TrackRecordReport::ReportSection

Rows are grouped into sections. Whenever the customer or project of the currently processed row differs from a previously processed row, a new section is declared. The report’s “sections” array should be accessed by section index (see module TrackRecordSections for details).

Section objects contain an array of ReportCell objects, just like a row, only this time each cell records the total hours in the column spanning all rows within the section. There is also a “#user_row_totals” array, again recording the hours for the user across the whole report time range and across all rows in the section.

The ReportSection object’s own hour totals give the sum of all hours by anybody across the whole report time range and all rows in the section. This is analogous to a ReportRow object’s totals.

Section totals are best calculated after the main per-row and per-column report data has been worked out for all rows and columns.

Attributes

cells[R]

Array of ReportCell objects. Analogous to the same-name array in a ReportRow, but each cell corresponds to all rows in this section.

user_row_totals[R]

Array of ReportUserRowTotal objects. Again, analogous to the same-name array in a ReportRow, but correspond to multiple rows.

Public Class Methods

new() click to toggle source
# File lib/track_record_report.rb, line 1056
def initialize
  super()
  @cells           = []
  @user_row_totals = []
end

Public Instance Methods

add_cell( cell, cell_index ) click to toggle source

Add the given ReportCell to the “@cells” array at the given cell index. If there is already a cell at this index, then add the hours to that cell. This makes it easy to iterate over rows and their cells, then add those hours progressively to the section cells to produce the multiple- row section totals.

# File lib/track_record_report.rb, line 1068
def add_cell( cell, cell_index )
  dup_or_calc( @cells, cell, cell_index )
  add!( cell )
end
add_user_row_total( user_row_total, user_index ) click to toggle source

Call to add ReportUserRowTotal objects to the row’s @#user_row_totals array at the given user index. Again, multiple calls for the same index cause hours to be added, as with “#add_cell” above.s

# File lib/track_record_report.rb, line 1077
def add_user_row_total( user_row_total, user_index )
  dup_or_calc( @user_row_totals, user_row_total, user_index )
end