Sha256: 9511c399f13050079dfabfd6af99b47ff4258c72f139afd0657a234c3cb52301

Contents?: true

Size: 492 Bytes

Versions: 5

Compression:

Stored size: 492 Bytes

Contents

module Tableview::Output
  class CSV
    require 'csv'
    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
    
    def to_s
      @table.to_s
    end
    
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
tableview-0.4.0 lib/tableview/output/csv.rb
tableview-0.3.3 lib/tableview/output/csv.rb
tableview-0.3.2 lib/tableview/output/csv.rb
tableview-0.3.1 lib/tableview/output/csv.rb
tableview-0.3.0 lib/tableview/output/csv.rb