Sha256: 4840b788135f1a7c7703e35141c3d9179fc1e704de63807a794b2b66913e3005

Contents?: true

Size: 622 Bytes

Versions: 4

Compression:

Stored size: 622 Bytes

Contents

require 'fastercsv'
module TableGo
  module Renderers
    class CsvRenderer
      include RendererBase

      def render_template
        ::FasterCSV.generate(:col_sep => ";", :row_sep => "\n", :force_quotes => true, :quote_char => '"') do |csv|
          csv << source_table.columns.map { |column| label_for_column(column) }
          source_table.collection.each do |record|
            csv << source_table.columns.map do |column|
              value = value_from_record_by_column(record, column)
              apply_formatter(record, column, value)
            end
          end
        end
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
table_go-0.2.2 lib/table_go/renderers/csv_renderer.rb
table_go-0.2.1 lib/table_go/renderers/csv_renderer.rb
table_go-0.2.0 lib/table_go/renderers/csv_renderer.rb
table_go-0.1.9 lib/table_go/renderers/csv_renderer.rb