Sha256: dd66ef4876690b314cbd3cd62b1b1060741feffeeaee853b75b79617ee1fd3fe

Contents?: true

Size: 655 Bytes

Versions: 3

Compression:

Stored size: 655 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 << table.columns.map { |column| label_for_column(column) } unless table.render_rows_only || table.without_header
          table.collection.each do |record|
            csv << 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

3 entries across 3 versions & 1 rubygems

Version Path
table_go-0.2.6 lib/table_go/renderers/csv_renderer.rb
table_go-0.2.5 lib/table_go/renderers/csv_renderer.rb
table_go-0.2.4 lib/table_go/renderers/csv_renderer.rb