Class: IdiCaptcha::Captcha
- Inherits:
-
Object
- Object
- IdiCaptcha::Captcha
- Defined in:
- lib/idi_captcha/captcha.rb
Class Method Summary collapse
Class Method Details
.generate(session) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/idi_captcha/captcha.rb', line 3 def self.generate(session) a = rand(1..9) b = rand(1..9) session[:captcha_question] = "#{a} + #{b}" session[:captcha_answer] = a + b end |
.valid?(session, input) ⇒ Boolean
10 11 12 |
# File 'lib/idi_captcha/captcha.rb', line 10 def self.valid?(session, input) session[:captcha_answer].to_i == input.to_i end |