Class: GymFinder::Client
- Inherits:
-
Object
- Object
- GymFinder::Client
- Defined in:
- lib/gym_finder/client.rb
Defined Under Namespace
Classes: CaptchaError, Conn, Error, Slot
Instance Method Summary collapse
- #fetch(**params) ⇒ Object
-
#initialize(username: ENV['GYM_FINDER_USERNAME'], password: ENV['GYM_FINDER_PASSWORD'], retry_captcha: 30) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(username: ENV['GYM_FINDER_USERNAME'], password: ENV['GYM_FINDER_PASSWORD'], retry_captcha: 30) ⇒ Client
Returns a new instance of Client.
73 74 75 76 77 78 79 80 81 82 |
# File 'lib/gym_finder/client.rb', line 73 def initialize( username: ENV['GYM_FINDER_USERNAME'], password: ENV['GYM_FINDER_PASSWORD'], retry_captcha: 30 ) @parser = Parser.new @username = username @password = password @retry_captcha = retry_captcha end |
Instance Method Details
#fetch(**params) ⇒ Object
84 85 86 87 88 89 90 91 92 93 |
# File 'lib/gym_finder/client.rb', line 84 def fetch(**params) captcha_error_count = 0 begin _fetch(**params) rescue CaptchaError => error captcha_error_count += 1 raise error if captcha_error_count == @retry_captcha retry end end |