gotcha 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/gotchas/sum_gotcha.rb +1 -1
- data/lib/gotcha.rb +5 -1
- data/lib/gotcha/version.rb +1 -1
- metadata +6 -6
data/gotchas/sum_gotcha.rb
CHANGED
@@ -6,7 +6,7 @@ class SumGotcha < Gotcha::Base
|
|
6
6
|
def initialize
|
7
7
|
rand1 = self.class.random_number_in_range
|
8
8
|
rand2 = self.class.random_number_in_range
|
9
|
-
@question = ["What is the sum of #{rand1} and #{rand2}?", "What is #{rand1} + #{rand2}?"]
|
9
|
+
@question = ["What is the sum of #{rand1} and #{rand2}?", "What is #{rand1} + #{rand2}?"][rand(2)]
|
10
10
|
@answer = rand1 + rand2
|
11
11
|
end
|
12
12
|
|
data/lib/gotcha.rb
CHANGED
@@ -17,11 +17,15 @@ module Gotcha
|
|
17
17
|
|
18
18
|
# Get a random Gotcha from the registered types
|
19
19
|
def self.random
|
20
|
-
if !@gotcha_types.nil? && type =
|
20
|
+
if !@gotcha_types.nil? && type = random_type
|
21
21
|
type.new
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
def self.random_type
|
26
|
+
@gotcha_types.respond_to?(:sample) ? @gotcha_types.sample : @gotcha_types[rand(@gotcha_types.size)]
|
27
|
+
end
|
28
|
+
|
25
29
|
def self.gotcha_types
|
26
30
|
@gotcha_types ||= []
|
27
31
|
end
|
data/lib/gotcha/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gotcha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 21
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- John Crepezzi
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-04-13 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -94,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
94
|
requirements: []
|
95
95
|
|
96
96
|
rubyforge_project: gotcha
|
97
|
-
rubygems_version: 1.
|
97
|
+
rubygems_version: 1.4.1
|
98
98
|
signing_key:
|
99
99
|
specification_version: 3
|
100
100
|
summary: A captcha library for auto-generating questions
|