Sha256: 88cbf65b625cbfef314b8e24d6fe9e11318602054ecef176ad3b86733c856ace

Contents?: true

Size: 732 Bytes

Versions: 1

Compression:

Stored size: 732 Bytes

Contents

require 'csv'

module DiningTable
  
  module Presenters

    class CSVPresenter < SpreadsheetPresenter

      attr_writer :output
      attr_accessor :stringio
      private :output, :stringio, :output=, :stringio=

      def initialize( *args )
        super
        self.output = ''
      end
      
      def identifier
        :csv
      end
      
      def output
        stringio.string
      end
      
      private
      
        def csv
          @csv ||= begin
            self.stringio = StringIO.new
            csv_options = options[:csv] || { }
            CSV.new(stringio, **csv_options)
          end
        end
        
        def add_row(array)
          csv.add_row( array )
        end

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dining-table-1.1.3 lib/dining-table/presenters/csv_presenter.rb