Sha256: a1b347a8c3e4a0834955161287b086800f32e27cfe089059ad35a25085514406

Contents?: true

Size: 714 Bytes

Versions: 11

Compression:

Stored size: 714 Bytes

Contents

require 'tempfile'
require 'csv'
require 'qualtrics/recipient_import_row'

module Qualtrics
  class PanelImportFile
    attr_reader :recipients

    def initialize(recipients)
      @recipients = recipients
    end

    def temp_file
      if @temp_file.nil?
        tmp_file = Tempfile.new('panel_import')
        csv_path = tmp_file.path
        tmp_file.close
        CSV.open(csv_path, 'wb', :force_quotes => true, :write_headers => true, :headers => Qualtrics::RecipientImportRow.fields) do |csv|
          @recipients.each do |recipient|
            csv << Qualtrics::RecipientImportRow.new(recipient).to_a
          end
        end
        @temp_file = csv_path
      end
      @temp_file
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
qualtrics-0.6.1 lib/qualtrics/panel_import_file.rb
qualtrics-0.6.0 lib/qualtrics/panel_import_file.rb
qualtrics-0.5.9b lib/qualtrics/panel_import_file.rb
qualtrics-0.5.9 lib/qualtrics/panel_import_file.rb
qualtrics-0.5.8 lib/qualtrics/panel_import_file.rb
qualtrics-0.5.7 lib/qualtrics/panel_import_file.rb
qualtrics-0.5.6 lib/qualtrics/panel_import_file.rb
qualtrics-0.5.5 lib/qualtrics/panel_import_file.rb
qualtrics-0.5.4 lib/qualtrics/panel_import_file.rb
qualtrics-0.5.3 lib/qualtrics/panel_import_file.rb
qualtrics-0.5.2 lib/qualtrics/panel_import_file.rb