rmathguard 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,5 +3,5 @@ require 'rmathguard/number'
3
3
  require 'rmathguard/expression'
4
4
 
5
5
  module RMathGuard
6
- VERSION = "0.1.1"
7
- end
6
+ VERSION = "0.1.2"
7
+ end
@@ -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
- @operator = %w(- +)[rand(2)]
48
- @operand1 = rand(@max_value)
49
- @operand2 = rand(@max_value)
50
- @result = eval("#{@operand1}#{@operator}#{@operand2}")
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
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - "Jakub Du\xC5\xA1ek"