Sha256: e97c540e980daab659fc36dfe6b12f4643e16c80500f2c8e3173980ff0572fca
Contents?: true
Size: 991 Bytes
Versions: 1
Compression:
Stored size: 991 Bytes
Contents
unless defined? $__rq_sleepcycle__ module RQ #{{{ LIBDIR = File::dirname(File::expand_path(__FILE__)) + File::SEPARATOR unless defined? LIBDIR # # the sleepcycle class provides timeouts for better than average polling # performance # class SleepCycle < Array #{{{ attr :min attr :max attr :range attr :inc def initialize min, max, inc #{{{ @min, @max, @inc = Float(min), Float(max), Float(inc) @range = @max - @min raise RangeError, "max < min" if @max < @min raise RangeError, "inc > range" if @inc > @range s = @min push(s) and s += @inc while(s <= @max) self[-1] = @max if self[-1] < @max reset #}}} end def next #{{{ ret = self[@idx] @idx = ((@idx + 1) % self.size) ret #}}} end def reset #{{{ @idx = 0 #}}} end #}}} end # class SleepCycle #}}} end # module RQ $__rq_sleepcycle__ = __FILE__ end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rq-0.1.7 | lib/rq-0.1.7/sleepcycle.rb |