Sha256: 57191398042e20c3eb0edb9ee8fb4770981523bebadf113d66305371cf7cf55e

Contents?: true

Size: 710 Bytes

Versions: 2

Compression:

Stored size: 710 Bytes

Contents

class Report
  class Csv
    class Table < Struct.new(:parent, :table)
      include Report::Utils
      def path
        return @path if defined?(@path)
        tmp_path = tmp_path(:hint => table.name, :extname => '.csv')
        File.open(tmp_path, 'wb') do |f|
          if table._head
            table._head.each(parent.report) do |row|
              f.write row.to_a.to_csv
            end
            f.write [].to_csv
          end
          if table._body
            f.write table._body.columns.map(&:name).to_csv
            table._body.each(parent.report) do |row|
              f.write row.to_a.to_csv
            end
          end
        end
        @path = tmp_path
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
report-0.0.2 lib/report/csv/table.rb
report-0.0.1 lib/report/csv/table.rb