Class: Waiter
- Inherits:
-
Object
- Object
- Waiter
- Defined in:
- lib/record_store/provider/provider_utils/waiter.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#message ⇒ Object
Returns the value of attribute message.
Instance Method Summary collapse
-
#initialize(message = nil) ⇒ Waiter
constructor
A new instance of Waiter.
- #wait(sleep_time, message: @message) ⇒ Object
Constructor Details
#initialize(message = nil) ⇒ Waiter
Returns a new instance of Waiter.
2 3 4 |
# File 'lib/record_store/provider/provider_utils/waiter.rb', line 2 def initialize( = nil) @message = || 'Waiting' end |
Instance Attribute Details
#message ⇒ Object
Returns the value of attribute message.
6 7 8 |
# File 'lib/record_store/provider/provider_utils/waiter.rb', line 6 def @message end |
Instance Method Details
#wait(sleep_time, message: @message) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/record_store/provider/provider_utils/waiter.rb', line 8 def wait(sleep_time, message: @message) while sleep_time > 0 wait_time = [10, sleep_time].min puts "#{} (#{sleep_time}s left)" if wait_time > 1 sleep(wait_time) sleep_time -= wait_time end end |