Module: TranslateClient::Helpers
- Defined in:
- lib/translate_client/helpers.rb
Constant Summary collapse
- POLLING_INTERVAL =
2
Class Method Summary collapse
Class Method Details
.poll_until(condition_proc = ->(e) { e.present? }, &block) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/translate_client/helpers.rb', line 8 def poll_until(condition_proc = ->(e) { e.present? }, &block) start = Time.now loop do result = block.call return result if condition_proc.call(result) if Time.now - start > 120 raise PresentableError.new("Timed out waiting for result. Please try again.") end sleep POLLING_INTERVAL print "." end ensure puts "" # finish line of dots end |