Class: EasyCaptchaSolver
- Inherits:
-
Object
- Object
- EasyCaptchaSolver
- Defined in:
- lib/easy_captcha_solver.rb
Instance Attribute Summary collapse
-
#captcha ⇒ Object
readonly
Returns the value of attribute captcha.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ EasyCaptchaSolver
constructor
A new instance of EasyCaptchaSolver.
Constructor Details
#initialize(options = {}) ⇒ EasyCaptchaSolver
Returns a new instance of EasyCaptchaSolver.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/easy_captcha_solver.rb', line 7 def initialize ( = {} ) image = [:image_path] if [:image_path] image = get_captcha_image([:image_url]) if [:image_url] throw Exception.new "Image path or image URL must be provided. Example: easy_c = EasyCaptcha.new( image_url: 'http://www.example.com/captcha' ) or easy_c = EasyCaptcha.new( image_path: './captcha.jpg' )" unless image # Try to solve the captcha and delete temp img if necessary solve_captcha(image) ensure File.delete(image) if [:image_url] && File.exist?(image) end |
Instance Attribute Details
#captcha ⇒ Object (readonly)
Returns the value of attribute captcha.
5 6 7 |
# File 'lib/easy_captcha_solver.rb', line 5 def captcha @captcha end |