Created
June 5, 2012 16:55
-
-
Save hersha/2876219 to your computer and use it in GitHub Desktop.
GodRB timeout condition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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