Class: Belzebuth::WaitCondition::Api
- Defined in:
- lib/belzebuth/wait_condition/api.rb
Constant Summary collapse
- MAX_SLEEP_TIME =
10
Instance Method Summary collapse
- #call(process) ⇒ Object
-
#initialize(uri, max_sleep_time = MAX_SLEEP_TIME) ⇒ Api
constructor
A new instance of Api.
- #sleep_time_between_condition ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(uri, max_sleep_time = MAX_SLEEP_TIME) ⇒ Api
Returns a new instance of Api.
10 11 12 13 14 |
# File 'lib/belzebuth/wait_condition/api.rb', line 10 def initialize(uri, max_sleep_time = MAX_SLEEP_TIME) @uri = URI(uri) @sleep_time = 1 @max_sleep_time = max_sleep_time end |
Instance Method Details
#call(process) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/belzebuth/wait_condition/api.rb', line 16 def call(process) Net::HTTP.get(@uri) true rescue => e @sleep_time = [@sleep_time +1, @max_sleep_time].min false end |
#sleep_time_between_condition ⇒ Object
24 25 26 |
# File 'lib/belzebuth/wait_condition/api.rb', line 24 def sleep_time_between_condition @sleep_time end |