Project

enat

0.0
No commit activity in last 3 years
No release in over 3 years
Executes a block of code at intervals of time, without guarantee of timing.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 2.0
~> 10.0
~> 3.0

Runtime

>= 3.2.13
 Project Readme

Every Now And Then

Build Status

It's quite simple, really - it lets you do something every specified interval of time. When supplied with a block, it yields the iteration count (starts at zero).

It requires 'active_support/time', so as to allow time intervals to be specified as 5.seconds, 6.7.days, etc. The 'every' method accepts non-zero numeric values (anything that responds to to_f).

If the operation inside the block takes longer than the specified interval, then the next iteration will begin immediately after the last.

To exit, simply break out of the loop.

Examples

require 'enat'

every 4.2.minutes do |i|
  puts "wheee! i've done this #{i} times!"
  break if i > 5
end

Installation

$ gem install enat