Project

xthreads

0.0
No commit activity in last 3 years
No release in over 3 years
xthreads
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

Introducing the Run Every gem

require 'run_every'

RunEvery.four.seconds {puts 'hello'}
#=> hello
#=> hello
#=> hello

RunEvery.new(seconds: 4) {puts 'hi'}
#=> hi
#=> hi
#=> hi

#RunEvery.two.minutes {puts 'hello'}

The Run Every gem is a simple timer with a code block. The interval can be set in seconds or minutes either using method chaining or through a hash passed into initialize(). The chaining method intervals include: one, two, three, four, five, ten, fifteen, twenty, twentyfive, thirty, forty, fifty.

Resources

update: 3-Apr-2011 @ 7:41pm

a = '12'
RunEvery.new(seconds: 6) do 
  if a == '12' then
    puts '..'
  elsif a == '1' then
    puts 'we have a winner'
    Thread.stop
  else
    puts 'nothing to see here'
  end
end

a = 1
#=> we have a winner

2 things worth noting: 1) variable scope can extend to outside the block. 2) The thread can be stopped from within the block using Thread.stop

every gem ruby simple timer