Sha256: 80b5bb909d9470dbea0ced409aca5f4102803268408c75e99b33e8ae10fbfb2f

Contents?: true

Size: 766 Bytes

Versions: 9

Compression:

Stored size: 766 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\./

      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

9 entries across 9 versions & 1 rubygems

Version Path
wice_grid-3.2.1 lib/wice_grid_spreadsheet.rb
wice_grid-3.2.1.pre3 lib/wice_grid_spreadsheet.rb
wice_grid-3.2.1.pre2 lib/wice_grid_spreadsheet.rb
wice_grid-3.2.1.pre1 lib/wice_grid_spreadsheet.rb
wice_grid-3.2.0 lib/wice_grid_spreadsheet.rb
wice_grid-3.2.0.pre4 lib/wice_grid_spreadsheet.rb
wice_grid-3.2.0.pre3 lib/wice_grid_spreadsheet.rb
wice_grid-3.2.0.pre2 lib/wice_grid_spreadsheet.rb
wice_grid-3.2.0.pre1 lib/wice_grid_spreadsheet.rb