Sha256: f529fd1732f10431dfec9233c59d727de424b374d19646d4e2820edb0710272e

Contents?: true

Size: 793 Bytes

Versions: 11

Compression:

Stored size: 793 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\./ || RUBY_VERSION =~ /^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

11 entries across 11 versions & 1 rubygems

Version Path
wice_grid-3.4.8 lib/wice/wice_grid_spreadsheet.rb
wice_grid-3.4.7 lib/wice/wice_grid_spreadsheet.rb
wice_grid-3.4.6 lib/wice/wice_grid_spreadsheet.rb
wice_grid-3.4.5 lib/wice/wice_grid_spreadsheet.rb
wice_grid-3.4.4 lib/wice/wice_grid_spreadsheet.rb
wice_grid-3.4.3 lib/wice/wice_grid_spreadsheet.rb
wice_grid-3.4.2 lib/wice/wice_grid_spreadsheet.rb
wice_grid-3.4.1 lib/wice/wice_grid_spreadsheet.rb
wice_grid-3.4.0 lib/wice/wice_grid_spreadsheet.rb
wice_grid-3.3.1 lib/wice/wice_grid_spreadsheet.rb
wice_grid-3.3.0 lib/wice/wice_grid_spreadsheet.rb