Class: Captcher::Captchas::CodeCaptcha
- Inherits:
-
BaseCaptcha
- Object
- BaseCaptcha
- Captcher::Captchas::CodeCaptcha
- Defined in:
- lib/captcher/captchas/code_captcha.rb
Constant Summary collapse
- SPECIAL_CHAR_CODES =
(91..96).freeze
Constants inherited from BaseCaptcha
Instance Attribute Summary
Attributes inherited from BaseCaptcha
Instance Method Summary collapse
-
#after_initialize ⇒ Object
rubocop:disable Naming/MemoizedInstanceVariableName.
-
#represent(format = :html, options = {}) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument.
-
#validate(confirmation) ⇒ Object
rubocop:enable Lint/UnusedMethodArgument.
Methods inherited from BaseCaptcha
#initialize, #own_config, restore, restore_or_create, #store
Constructor Details
This class inherits a constructor from Captcher::BaseCaptcha
Instance Method Details
#after_initialize ⇒ Object
rubocop:disable Naming/MemoizedInstanceVariableName
9 10 11 |
# File 'lib/captcher/captchas/code_captcha.rb', line 9 def after_initialize @payload ||= random_text end |
#represent(format = :html, options = {}) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument
15 16 17 |
# File 'lib/captcher/captchas/code_captcha.rb', line 15 def represent(format = :html, = {}) Captcher::TextImage.new(@payload, own_config).generate end |
#validate(confirmation) ⇒ Object
rubocop:enable Lint/UnusedMethodArgument
20 21 22 |
# File 'lib/captcher/captchas/code_captcha.rb', line 20 def validate(confirmation) confirmation.to_s.strip.casecmp(@payload).zero? end |