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!, url_with_version, use
Class Method Details
.touch_existing(id) ⇒ Object
12
13
14
|
# File 'lib/quandl/client/models/dataset.rb', line 12
def self.touch_existing(id)
put(File.join(Quandl::Client::Base.url_with_version, "datasets/#{id}/touch")).exists?
end
|
Instance Method Details
#data ⇒ Object
69
70
71
|
# File 'lib/quandl/client/models/dataset.rb', line 69
def data
dataset_data.data? ? dataset_data.data : data_scope
end
|
#data=(value) ⇒ Object
73
74
75
|
# File 'lib/quandl/client/models/dataset.rb', line 73
def data=(value)
dataset_data.data = value
end
|
#data_scope ⇒ Object
93
94
95
|
# File 'lib/quandl/client/models/dataset.rb', line 93
def data_scope
@data_scope ||= Quandl::Client::Dataset::Data.with_id(id)
end
|
#dataset_data ⇒ Object
97
98
99
|
# File 'lib/quandl/client/models/dataset.rb', line 97
def dataset_data
@dataset_data ||= Quandl::Client::Dataset::Data.new( id: id )
end
|
#delete_data ⇒ Object
77
78
79
80
81
82
|
# File 'lib/quandl/client/models/dataset.rb', line 77
def delete_data
return false if new_record?
self.class.destroy_existing("#{id}/data").saved?
end
|
#delete_rows(*dates) ⇒ Object
84
85
86
87
88
89
90
91
|
# File 'lib/quandl/client/models/dataset.rb', line 84
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
|
118
119
120
121
|
# File 'lib/quandl/client/models/dataset.rb', line 118
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
63
64
65
|
# File 'lib/quandl/client/models/dataset.rb', line 63
def full_code
File.join(self.source_code.to_s, self.code.to_s)
end
|
#full_url ⇒ Object
59
60
61
|
# File 'lib/quandl/client/models/dataset.rb', line 59
def full_url
File.join(Quandl::Client::Base.url.gsub('api/', ''), full_code)
end
|
#reference_url ⇒ Object
52
53
54
|
# File 'lib/quandl/client/models/dataset.rb', line 52
def reference_url
self.display_url
end
|
#reference_url=(value) ⇒ Object
55
56
57
|
# File 'lib/quandl/client/models/dataset.rb', line 55
def reference_url=(value)
self.display_url = value
end
|
#reload ⇒ Object
101
102
103
104
105
|
# File 'lib/quandl/client/models/dataset.rb', line 101
def reload
@dataset_data = nil
@data_scope = nil
@full_code = nil
end
|
#save_dataset_data ⇒ Object
111
112
113
114
115
116
|
# File 'lib/quandl/client/models/dataset.rb', line 111
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
25
26
27
|
# File 'lib/quandl/client/models/dataset.rb', line 25
def source
@source ||= Quandl::Client::Source.find(self.source_code)
end
|