A little Ruby poem, engendered during a discussion of how to run a block at fixed time intervals (like cron).
gem install activepoem
class Fixnum
def minutely_do(times = 0)
begin
sleep(self*60)
end while yield and (times -= 1) != 0
end
end
some literature
Now we can write:
1.minutely_do { puts "a minute!" or true }
And that totally rhymes.
We would need to put the call in its own thread if we wanted to use this in real life, in most cases.
What about this sort of syntax, and using the ruby throw/catch capabilties:
implementation is left up to the reader :)