Class: EasyCaptchaSolver

Inherits:
Object
  • Object
show all
Defined in:
lib/easy_captcha_solver.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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 ( options = {} )
  image = options[:image_path] if options[:image_path]
  image = get_captcha_image(options[:image_url]) if options[: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 options[:image_url] && File.exist?(image)
end

Instance Attribute Details

#captchaObject (readonly)

Returns the value of attribute captcha.



5
6
7
# File 'lib/easy_captcha_solver.rb', line 5

def captcha
  @captcha
end