Sha256: 0f9b0d5bab22afcf93b1c5f343b81cc6821115ec78072b27af9b6cf0d3451984

Contents?: true

Size: 419 Bytes

Versions: 6

Compression:

Stored size: 419 Bytes

Contents

require 'csv'

module Repor
  module Serializers
    class CsvSerializer < TableSerializer
      def csv_text
        CSV.generate do |csv|
          csv << headers
          each_row { |row| csv << row }
        end
      end

      def save(filename = self.filename)
        File.open(filename, 'w') { |f| f.write data }
      end

      def filename
        "#{caption.parameterize}.csv"
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
repor-0.1.0 lib/repor/serializers/csv_serializer.rb
repor-0.0.5 lib/repor/serializers/csv_serializer.rb
repor-0.0.4 lib/repor/serializers/csv_serializer.rb
repor-0.0.3 lib/repor/serializers/csv_serializer.rb
repor-0.0.2 lib/repor/serializers/csv_serializer.rb
repor-0.0.1 lib/repor/serializers/csv_serializer.rb