Class: Tableview::Output::CSV

Inherits:
Object
  • Object
show all
Defined in:
lib/tableview/output/csv.rb

Instance Method Summary collapse

Instance Method Details

#process(tv) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/tableview/output/csv.rb', line 4

def process(tv)
  @table = ::CSV.generate("") { |csv|
    tv.parts.each do |part|
      part.rows.each do |row|
        r = []
        row.cells.each do |cell| 
          r << cell.contents
          r += [nil] * (cell.options[:colspan] - 1) if cell.options[:colspan]
        end
        csv << r
      end
    end
  }
end

#to_sObject



19
20
21
# File 'lib/tableview/output/csv.rb', line 19

def to_s
  @table.to_s
end