Class: StupidCaptcha::Captcha
- Inherits:
-
Object
- Object
- StupidCaptcha::Captcha
- Includes:
- StupidCaptcha
- Defined in:
- lib/stupid_captcha.rb
Constant Summary
Constants included from StupidCaptcha
Instance Attribute Summary collapse
-
#hash ⇒ Object
Returns the value of attribute hash.
-
#img ⇒ Object
Returns the value of attribute img.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
Methods included from StupidCaptcha
#backgrounds, #check, #encrypt, #files, #fonts, #random_string, #salt, setup
Instance Attribute Details
#hash ⇒ Object
Returns the value of attribute hash.
68 69 70 |
# File 'lib/stupid_captcha.rb', line 68 def hash @hash end |
#img ⇒ Object
Returns the value of attribute img.
68 69 70 |
# File 'lib/stupid_captcha.rb', line 68 def img @img end |
#text ⇒ Object
Returns the value of attribute text.
68 69 70 |
# File 'lib/stupid_captcha.rb', line 68 def text @text end |
Instance Method Details
#render ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/stupid_captcha.rb', line 70 def render icon = Magick::Image.read(backgrounds.sample).first drawable = Magick::Draw.new drawable.pointsize = 32.0 drawable.font = fonts.sample drawable.fill = colors.sample drawable.gravity = Magick::CenterGravity # Tweak the font to draw slightly up and left from the center # drawable.annotate(icon, 0, 0, -3, -6, @order.quantity.to_s) drawable.annotate(icon, 0, 0, 0,0, text) img = icon end |
#reset ⇒ Object
86 87 88 89 90 |
# File 'lib/stupid_captcha.rb', line 86 def reset @text = random_string(rand(3)+5) @hash = encrypt(text, salt) @img = render end |
#to_blob ⇒ Object
92 93 94 |
# File 'lib/stupid_captcha.rb', line 92 def to_blob img.to_blob end |