A more ruby way of writing this method would be to use the #count method on Enumerable.

Check that out and see if you can use it instead.

It would be something like:

    @files.find({ :filename => filename }).sort({ :uploadDate => -1 }).skip(cutoff).count do |doc|
         delete(doc['_id'])
     end

This works as long as delete(doc['_id']) returns nil or false if the doc is not actually deleted.