views:

88

answers:

2

I'm trying to write an iterator in ruby that sends a callback on the first of every month.

How would you write something like that?

+2  A: 
if my_date.beginning_of_day == Time.now.beginning_of_month
  my callback
end
shingara
That would be Rails specific. But yes, I do see the `ruby-on-rails` tag.
Swanand
yes this technique need ActiveSupport
shingara
+4  A: 
if Date.today.day == 1
  #do something
end

I'm not sure what you mean by an iterator - i hope you don't mean some program that keeps looping, constantly asking if today is the first day of the month? Sounds like a waste of resources. Use crontab :)

Max Williams
Cronjob! All obeisances to our fearless leader Cronos.
Trip