Class CAPTCHA::Web
In: lib/captcha.rb
Parent: Object

This class provides a way to use the ObfuscatedImage on a web page, in concert with an encrypted digest and key.

Methods

Included Modules

ParameterValidator

Constants

VALID_CONFIG_VARS = { :key_length=>KEY_LENGTH, :font=>FONT, :font_size=>FONT_SIZE, :image_dir=>IMAGE_DIR, :image_uri=>IMAGE_URI, :clean_up_interval=>CLEAN_UP_INTERVAL, :template_file=>TEMPLATE, :use_chars=>USE_CHARS, :x_spacing=>X_SPACING, :y_wiggle=>Y_WIGGLE, :rotation=>ROTATION }   the list of variables that may be validly specified in a configuration file, or as an option to ‘new

Attributes

clean_up_interval  [RW] 
digest  [R] 
font  [RW] 
font_size  [RW] 
image_dir  [RW] 
image_uri  [RW] 
key  [R] 
rotation  [RW] 
template_file  [RW] 
x_spacing  [RW] 
y_wiggle  [RW] 

Public Class methods

Create a new Web object, configuring it from the file with the given name. Any variables not set in the configuration file will be given default values.

Test the given key against the given digest. If the digest was created from the given key, return true, otherwise return false.

Initialize a new Web object with the given values. The valid parameters are the same as the valid configuration variables (VALID_CONFIG_VARS).

Public Instance methods

Look in the image directory, deleting any images there that are more than ‘clean_up_interval’ seconds old.

Get the name of the image file. This will generate the file name if it has not yet been generated.

Get the ObfuscatedImage that will be shown on the page. If the image has not yet been created, this will create it.

Convert the object to HTML, using the given template file name if provided. If a template is not given here, the one used to configure the object will be used instead. The template file should contain the following tokens:

  • %%IMAGE%%: the file name of the image
  • %%IMAGEURI%%: the web-accessible directory containing the image
  • %%DIGEST%%: the digest string
  • %%IMAGEWIDTH%%: the width of the image file
  • %%IMAGEHEIGHT%%: the height of the image file

[Validate]