simple_time_series 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 77f5fe74aadbbee67156c46c190f73ec8a722226
4
- data.tar.gz: 9d67c1568ee6d40198c141ba4e7e0a4f6b222122
3
+ metadata.gz: cd605120e06fab71a1bccb9dac79ab16a6880474
4
+ data.tar.gz: 5a1c66e55f196de999eb07011a60ab3a801e09bb
5
5
  SHA512:
6
- metadata.gz: dc234775ae834f544f18bf21cf04c2127eb80bb07cbaafe34592eb604b3dfbabdba07f04f5c5785eb9ac61454208a1af9ac54dc12355cd09a419993b449b65fa
7
- data.tar.gz: 41cfa5ab40b9d5ed128b88df8b264464b6f98742e5a0ab373dcd561851101f8a418d1360afe615dae3cb5ba41c30070849153801174ac5503e64e199d31333c4
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
@@ -1,3 +1,3 @@
1
1
  class SimpleTimeSeries
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -274,12 +274,19 @@ describe SimpleTimeSeries do
274
274
 
275
275
  end
276
276
 
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
- # end
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
- #end
290
+ end
284
291
 
285
292
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_time_series
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Lavin