File Directory Ruby

def delete_older(dir, time)
  save = Dir.getwd
  Dir.chdir(dir)
  Dir.foreach(".") do |entry|
    # We're not handling directories here
    next if File.stat(entry).directory?
    # Use the modification time
    if File.mtime(entry) < time
      File.unlink(entry)
    end
  end
  Dir.chdir(save)
end
delete_older("/tmp",Time.local(2001,3,29,18,38,0))