Module: SimpleCaptcha::ImageHelpers

Includes:
ConfigTasks
Included in:
SimpleCaptchaController
Defined in:
lib/simple_captcha_image.rb

Overview

:nodoc

Constant Summary collapse

IMAGE_STYLES =
[
  'embosed_silver',
  'simply_red',
  'simply_green',
  'simply_blue',
  'distorted_black',
  'all_black',
  'charcoal_grey',
  'almost_invisible'
]
DISTORTIONS =
['low', 'medium', 'high']

Class Method Summary collapse

Class Method Details

.distortion(key = 'low') ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/simple_captcha_image.rb', line 30

def distortion(key='low')
  key = 
    key == 'random' ?
    DISTORTIONS[rand(DISTORTIONS.length)] :
    DISTORTIONS.include?(key) ? key : 'low'
  case key
    when 'low' then return [0 + rand(2), 80 + rand(20)]
    when 'medium' then return [2 + rand(2), 50 + rand(20)]
    when 'high' then return [4 + rand(2), 30 + rand(20)]
  end
end

.image_style(key = 'simply_blue') ⇒ Object



25
26
27
28
# File 'lib/simple_captcha_image.rb', line 25

def image_style(key='simply_blue')
  return IMAGE_STYLES[rand(IMAGE_STYLES.length)] if key=='random'
  IMAGE_STYLES.include?(key) ? key : 'simply_blue'
end