class Grell::Reader

A tooling class, it waits a maximum of max_waiting for an action to finish. If the action is not finished by then, it will continue anyway. The wait may be long but we want to finish it as soon as the action has finished

Public Class Methods

wait_for(action, max_waiting, sleeping_time) { || ... } click to toggle source
# File lib/grell/reader.rb, line 6
def self.wait_for(action, max_waiting, sleeping_time)
  time_start = Time.now
  action.call()
  return if yield
  while (Time.now < time_start + max_waiting)
    action.call()
    break if yield
    sleep(sleeping_time)
  end
end