simple_time_series 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd605120e06fab71a1bccb9dac79ab16a6880474
|
4
|
+
data.tar.gz: 5a1c66e55f196de999eb07011a60ab3a801e09bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a7bc9c117b71584071b279137b3d2db9cc80599dc3021495b9f2318d51d7f25dd48877350a6413bd5613954b999e4d014eb3bdfa82159440eb1aedafb56118d
|
7
|
+
data.tar.gz: 1be9e907f24713542848055f1dd1a9cd0d2c256798ad55b3b8b64cd158edddb57a8163ea342b5a864e7cff55304212eefb942a141cdeca3861a4c42796a25935
|
@@ -21,6 +21,22 @@ class SimpleTimeSeries
|
|
21
21
|
find(what, date, end_date).unshift(what)
|
22
22
|
end
|
23
23
|
|
24
|
+
def data_array(*data_var_names, opts)
|
25
|
+
err_msg = "The last parameter passed to #data_array must be a hash of start/end values.\n"
|
26
|
+
err_msg += "Example: {:start => 'Tuesday', :end => '2014-01-06'}\n"
|
27
|
+
err_msg += "If you want to use all observations, you can pass a blank hash, like {}\n"
|
28
|
+
raise err_msg unless opts
|
29
|
+
data_array = []
|
30
|
+
Array(data_var_names).each do |name|
|
31
|
+
if opts[:start] && opts[:end]
|
32
|
+
data_array << find(name, opts[:start], opts[:end])
|
33
|
+
else
|
34
|
+
data_array << current(name)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
data_array
|
38
|
+
end
|
39
|
+
|
24
40
|
def current(what)
|
25
41
|
send what.to_sym
|
26
42
|
end
|
@@ -274,12 +274,19 @@ describe SimpleTimeSeries do
|
|
274
274
|
|
275
275
|
end
|
276
276
|
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
277
|
+
describe "#data_array" do
|
278
|
+
|
279
|
+
it "builds an array of arrays with all time_vars" do
|
280
|
+
@my_data.data_array('tasks_done', {}).should == [ @my_data.current('tasks_done') ]
|
281
|
+
@my_data.data_array('tasks_done', 'pizzas', {}).should == [ @my_data.current('tasks_done'),
|
282
|
+
@my_data.current('pizzas') ]
|
283
|
+
@my_data.data_array('tasks_done', 'pizzas', {:start => 'Tuesday', :end => 'Thursday'}).
|
284
|
+
should == [ @my_data.find('tasks_done','Tuesday','Thursday'),
|
285
|
+
@my_data.find('pizzas', '2014-01-03', 'Jan 5, 2014') ]
|
286
|
+
#@my_data.data_array(['tasks_done', 'pizzas']).should == [ @my_data.current('tasks_done'),
|
287
|
+
# @my_data.current('pizzas') ]
|
288
|
+
end
|
282
289
|
|
283
|
-
|
290
|
+
end
|
284
291
|
|
285
292
|
end
|