Skip to content

Instantly share code, notes, and snippets.

@hersha
Created June 5, 2012 16:55
Show Gist options
  • Save hersha/2876219 to your computer and use it in GitHub Desktop.
Save hersha/2876219 to your computer and use it in GitHub Desktop.
GodRB timeout condition
module God
module Conditions
class Timeout < PollCondition
attr_accessor :timeout
def initialize
super
@last_time = Time.now
end
def reset
@last_time = Time.now
end
def valid?
valid = true
valid &= complain("Attribute 'timeout' must be specified", self) if self.timeout.nil?
valid
end
def test
if Time.now > (@last_time + self.timeout)
return true
else
return false
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment