Class: Gogdb::Utils
- Inherits:
-
Object
- Object
- Gogdb::Utils
- Defined in:
- lib/gogdb/utils.rb
Instance Method Summary collapse
-
#initialize(logger = Logger.new({})) ⇒ Utils
constructor
A new instance of Utils.
-
#retryConnection(url) ⇒ Boolean
Retries connection to GOG.com incrementally (every 10n seconds, up to 120).
Constructor Details
#initialize(logger = Logger.new({})) ⇒ Utils
Returns a new instance of Utils.
4 5 6 |
# File 'lib/gogdb/utils.rb', line 4 def initialize(logger=Logger.new({})) @logger = logger end |
Instance Method Details
#retryConnection(url) ⇒ Boolean
Retries connection to GOG.com incrementally (every 10n seconds, up to 120)
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/gogdb/utils.rb', line 12 def retryConnection(url) @count = 1 ph = Net::Ping::HTTP.new(url) while true do if ph.ping? @logger.warning "Connection to gog.com established successfully. Retrying previous task..." true else @logger.error "Cannot establish connection. Retrying in #{@count * 10} seconds..." end sleep(10 * @count) @count += 1 if @count < 12 end end |