Method: QueryReport::ColumnModule#column_total_with_colspan

Defined in:
lib/query_report/column.rb

#column_total_with_colspanObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/query_report/column.rb', line 23

def column_total_with_colspan
  total_with_colspan = []
  colspan = 0
  total_text_printed = false
  columns.each do |column|
    if column.has_total?
      if colspan > 0
        title = total_text_printed ? '' : I18n.t('query_report.total')
        total_with_colspan << (colspan == 1 ? {content: title} : {content: title, colspan: colspan})
      end
      total_with_colspan << {content: column.total}
      total_text_printed = true
      colspan = 0
    else
      colspan += 1
    end
  end
  if colspan > 0
    total_with_colspan << {content: '', colspan: colspan}
  end
  total_with_colspan
end