Class: Swivel::DataSet

Inherits:
Response show all
Defined in:
lib/swivel.rb

Instance Attribute Summary

Attributes inherited from Response

#disable_auto_refresh, #hash_doc, #refreshed_at

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Response

#[], #id, #initialize, #method_missing, #to_param, #to_s, #to_xml

Constructor Details

This class inherits a constructor from Swivel::Response

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Swivel::Response

Class Method Details

.resourceObject

Append new data to this data_set. Passed in options must contain csv data. This csv data must adhrere to the same column structure as the originally uploaded data_set.

data_set = swivel.data_set id
data_set.append! :data => `/tmp/append.csv`


431
432
433
# File 'lib/swivel.rb', line 431

def self.resource
  'data-set'
end

Instance Method Details

#append!(options = Hash.new) ⇒ Object



435
436
437
438
439
440
441
442
443
# File 'lib/swivel.rb', line 435

def append! options = Hash.new
  options.merge! :mode => 'append', :id => self.id
  raise 'feed me data!' if options[:data].blank?
  appended_data_set = @connection.upload! options
  @refreshed_at = nil
  @retried = false
  @doc = appended_data_set.instance_variable_get :@doc
  self
end

#csvObject



462
463
464
# File 'lib/swivel.rb', line 462

def csv
  @connection.call "/data_sets/csv/#{id}"
end

#replace!(options = Hash.new) ⇒ Object

Replace data in this data_set. Passed in options must contain csv data. This csv data must adhere to the same column structure as the originally uploaded data set.

data_set = swivel.data_set id
data_set.replace! :data => `/tmp/replace.csv`


452
453
454
455
456
457
458
459
460
# File 'lib/swivel.rb', line 452

def replace! options = Hash.new
  options.merge! :mode => 'replace', :id => self.id
  raise 'feed me data!' if options[:data].blank?
  replaced_data_set = @connection.upload! options
  @refreshed_at = nil
  @retried = false
  @doc = replaced_data_set.instance_variable_get :@doc
  self
end