Class: Qualtrics::PanelImportFile

Inherits:
Object
  • Object
show all
Defined in:
lib/qualtrics/panel_import_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(recipients) ⇒ PanelImportFile

Returns a new instance of PanelImportFile.



9
10
11
# File 'lib/qualtrics/panel_import_file.rb', line 9

def initialize(recipients)
  @recipients = recipients
end

Instance Attribute Details

#recipientsObject (readonly)

Returns the value of attribute recipients.



7
8
9
# File 'lib/qualtrics/panel_import_file.rb', line 7

def recipients
  @recipients
end

Instance Method Details

#temp_fileObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/qualtrics/panel_import_file.rb', line 13

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