Method: Xport::ExportBuilder#groups_with_offset_and_colspan

Defined in:
lib/xport/export_builder.rb

#groups_with_offset_and_colspanObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/xport/export_builder.rb', line 33

def groups_with_offset_and_colspan
  offset  = 0
  colspan = 1
  [].tap do |result|
    groups.each do |group|
      last = result.last
      # check if current group is same as last group
      if last && last[0] == group
        # if group is the same, update colspan
        last[2] += 1
      else
        result << [group, offset, colspan]
      end
      offset  += 1
    end
  end
end