Class: Captchah::Generators::Captcha
- Inherits:
-
Object
- Object
- Captchah::Generators::Captcha
- Defined in:
- lib/captchah/generators/captcha.rb
Constant Summary collapse
- DEFAULT_DIFFICULTY =
3- DEFAULT_EXPIRY =
10.minutes
- DEFAULT_WIDTH =
140- DEFAULT_ACTION_LABEL =
'Type the letters you see:'- DEFAULT_RELOAD_LABEL =
'Reload'- DEFAULT_RELOAD_MAX =
5- DEFAULT_RELOAD_COUNT =
1- DEFAULT_PUZZLE_FONT =
'Verdana'
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Captcha
constructor
A new instance of Captcha.
Constructor Details
#initialize(args = {}) ⇒ Captcha
Returns a new instance of Captcha.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/captchah/generators/captcha.rb', line 19 def initialize(args = {}) @id = args[:id] || SecureRandom.uuid @difficulty = args[:difficulty] || DEFAULT_DIFFICULTY @expiry = args[:expiry] || DEFAULT_EXPIRY @width = (args[:width] || DEFAULT_WIDTH).to_i @action_label = args[:action_label] || DEFAULT_ACTION_LABEL @reload_label = args[:reload_label] || DEFAULT_RELOAD_LABEL @reload_max = args[:reload_max] || DEFAULT_RELOAD_MAX @reload_count = args[:reload_count] || DEFAULT_RELOAD_COUNT @reload = args[:reload] == false ? false : allow_reload? @css = (args[:css] != false) @csp_nonce = args[:csp_nonce] @required = !!args[:required] # rubocop:disable Style/DoubleNegation @puzzle_font = args[:puzzle_font] || DEFAULT_PUZZLE_FONT end |
Class Method Details
.call(*args) ⇒ Object
15 16 17 |
# File 'lib/captchah/generators/captcha.rb', line 15 def self.call(*args) new(*args).send(:call) end |