Sha256: 319eb570eeefc67db4e56615b4c597ef4ed3dbe9b65c33989b0b351091982c5d

Contents?: true

Size: 798 Bytes

Versions: 27

Compression:

Stored size: 798 Bytes

Contents

# encoding: UTF-8
require 'csv'

module Wice
  class Spreadsheet  #:nodoc:

    attr_reader :tempfile
    # CSV in 1.9.1 is a version of FasterCSV
    if RUBY_VERSION == '1.9.1' || RUBY_VERSION == '1.9.2'

      def initialize(name, field_separator)  #:nodoc:
        @tempfile = Tempfile.new(name)
        @csv = CSV.new(@tempfile, :col_sep => field_separator)
      end

      def << (row)  #:nodoc:
        @csv << row
      end
      
    else
      def initialize(name, field_separator)  #:nodoc:
        @tempfile = Tempfile.new(name)
        @field_separator = field_separator
      end

      def << (row)  #:nodoc:
        CSV::Writer.generate(@tempfile, @field_separator) do |csv|
           csv << row.map(&:to_s)
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 4 rubygems

Version Path
wice_grid_mongo-6.2.4 lib/wice_grid_spreadsheet.rb
wice_grid-3.0.4 lib/wice_grid_spreadsheet.rb
wice_grid-3.0.3 lib/wice_grid_spreadsheet.rb
wice_grid-3.0.2 lib/wice_grid_spreadsheet.rb
wice_grid-3.0.1 lib/wice_grid_spreadsheet.rb
wice_grid-3.0.0 lib/wice_grid_spreadsheet.rb
wice_grid_mongoid-6.2.3 lib/wice_grid_spreadsheet.rb
wice_grid_mongoid-6.2.2 lib/wice_grid_spreadsheet.rb
wice_grid_mongoid-6.2.1 lib/wice_grid_spreadsheet.rb
wice_grid_mongoid-6.2.0 lib/wice_grid_spreadsheet.rb
wice_grid_mongoid-6.1.1 lib/wice_grid_spreadsheet.rb
wice_grid_mongoid-6.1.0 lib/wice_grid_spreadsheet.rb
wice_grid-3.0.0.pre4 lib/wice_grid_spreadsheet.rb
wice_grid-3.0.0.pre3 lib/wice_grid_spreadsheet.rb
wice_grid_mongoid-6.0.10 lib/wice_grid_spreadsheet.rb
wice_grid_mongoid-6.0.9 lib/wice_grid_spreadsheet.rb
wice_grid-3.0.0.pre2 lib/wice_grid_spreadsheet.rb
wice_grid-3.0.0.pre1 lib/wice_grid_spreadsheet.rb
wice_grid_mongoid-6.0.8 lib/wice_grid_spreadsheet.rb
wice_grid_mongoid-6.0.7 lib/wice_grid_spreadsheet.rb