Sha256: 8572cdf67d3bc1e1087287e3899b9f25982e7cdff32a571803a82cf86e106bae

Contents?: true

Size: 491 Bytes

Versions: 2

Compression:

Stored size: 491 Bytes

Contents

module Tableview::Ouput
  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

2 entries across 2 versions & 1 rubygems

Version Path
tableview-0.2.0 lib/tableview/output/csv.rb
tableview-0.1.0 lib/tableview/output/csv.rb