Class: Quandl::Client::Dataset
- Inherits:
-
Base
- Object
- Base
- Quandl::Client::Dataset
show all
- Defined in:
- lib/quandl/client/models/dataset.rb
Defined Under Namespace
Classes: Data
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
her_api, models, models_use_her_api!, use
Class Method Details
.touch_existing(id) ⇒ Object
9
10
11
|
# File 'lib/quandl/client/models/dataset.rb', line 9
def self.touch_existing(id)
put(File.join(Quandl::Client::Base.url, "datasets/#{id}/touch")).exists?
end
|
Instance Method Details
#data ⇒ Object
55
56
57
|
# File 'lib/quandl/client/models/dataset.rb', line 55
def data
dataset_data.data? ? dataset_data.data : Quandl::Client::Dataset::Data.with_id(id)
end
|
#data=(value) ⇒ Object
59
60
61
|
# File 'lib/quandl/client/models/dataset.rb', line 59
def data=(value)
dataset_data.data = value
end
|
#dataset_data ⇒ Object
79
80
81
|
# File 'lib/quandl/client/models/dataset.rb', line 79
def dataset_data
@dataset_data ||= Quandl::Client::Dataset::Data.new( id: id )
end
|
#delete_data ⇒ Object
63
64
65
66
67
68
|
# File 'lib/quandl/client/models/dataset.rb', line 63
def delete_data
return false if new_record?
self.class.destroy_existing("#{id}/data").saved?
end
|
#delete_rows(*dates) ⇒ Object
70
71
72
73
74
75
76
77
|
# File 'lib/quandl/client/models/dataset.rb', line 70
def delete_rows(*dates)
return false if new_record?
query = { dates: Array(dates).flatten }.to_query
self.class.destroy_existing("#{id}/data/rows?#{query}").saved?
end
|
94
95
96
97
|
# File 'lib/quandl/client/models/dataset.rb', line 94
def enforce_required_formats
self.locations_attributes = locations_attributes.to_json if locations_attributes.respond_to?(:to_json) && !locations_attributes.kind_of?(String)
end
|
#full_code ⇒ Object
49
50
51
|
# File 'lib/quandl/client/models/dataset.rb', line 49
def full_code
@full_code ||= File.join(self.source_code, self.code)
end
|
#save_dataset_data ⇒ Object
87
88
89
90
91
92
|
# File 'lib/quandl/client/models/dataset.rb', line 87
def save_dataset_data
dataset_data.id = id
dataset_data.save
attributes.each{|k,v| attributes[k] = dataset_data.attributes[k] if dataset_data.attributes.has_key?(k) }
end
|
#source ⇒ Object
22
23
24
|
# File 'lib/quandl/client/models/dataset.rb', line 22
def source
@source ||= Quandl::Client::Source.find(self.source_code)
end
|