Zachary Holt
6/5/2007 5:46:00 AM
On Jun 4, 2007, at 10:24 PM, Micah Carrick wrote:
> Hey ya'll.
Hey.
> I'm brand new to Ruby.
Welcome. This is my first post to this list. So we're on a par.
> def delete_if_old(file)
> t = (Time.new-(60*60*24*30)).strftime("%Y%m%d_%H%M%S").to_i
You might want Time.now.to_i + ( 60 * 60 * 24 * 30 )
> if file.to_i < t
You're calling to_i on a String here. I bet that "if" clause always
hits.
> File.delete(LOG_DIR + file)
> end
> end
>
> Dir.foreach(LOG_DIR) { |f| delete_if_old f }
> #---------------------------------------------------------------------
> ----------
Is it possible that the first time delete_if_old is called, it's
passed "." (dot)?