advanced_math 0.0.2 → 0.0.3

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.
Files changed (2) hide show
  1. data/lib/simple_moving_average.rb +4 -0
  2. metadata +3 -3
@@ -17,6 +17,8 @@ module Math
17
17
  # array of values used as temporary storage
18
18
  ###
19
19
  def initialize(range)
20
+ raise ArgumentError, "Range is nil" unless (range);
21
+ raise ArgumentError, "Range must be >= 1" unless range.to_i >= 1;
20
22
  @range = range.to_i;
21
23
  @sum = 0;
22
24
  @values = Array.new();
@@ -28,6 +30,8 @@ module Math
28
30
  # Otherwise compute the SMA and return the value.
29
31
  ###
30
32
  def add(value)
33
+ raise ArgumentError, "Value is nil" unless (value);
34
+
31
35
  # add the value to the end of the array.
32
36
  @values.push(value);
33
37
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: advanced_math
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - G Nagel