rmathguard 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rmathguard.rb +2 -2
- data/lib/rmathguard/expression.rb +7 -4
- metadata +2 -2
data/lib/rmathguard.rb
CHANGED
@@ -11,6 +11,7 @@ module RMathGuard
|
|
11
11
|
@row_count = options[:row_count] || 5
|
12
12
|
@col_count = options[:col_count] || options[:column_count] || 3
|
13
13
|
@sep_size = options[:sep_size] || 2
|
14
|
+
@negative = options[:negative] || false
|
14
15
|
|
15
16
|
unless @row_count == 5 && @col_count == 3
|
16
17
|
RMathGuard::Numbers.resize(@row_count, @col_count)
|
@@ -44,10 +45,12 @@ module RMathGuard
|
|
44
45
|
|
45
46
|
private
|
46
47
|
def generate
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
begin
|
49
|
+
@operator = %w(- +)[rand(2)]
|
50
|
+
@operand1 = rand(@max_value)
|
51
|
+
@operand2 = rand(@max_value)
|
52
|
+
@result = eval("#{@operand1}#{@operator}#{@operand2}")
|
53
|
+
end until @result >= 0 || @negative
|
51
54
|
end
|
52
55
|
end
|
53
56
|
end
|