我很惊讶我找不到这个问题的答案,但我需要选择在Time.now和1.day.ago之间修改的所有文件。显然我在处理ruby文件或FileUtil类时并不期望一个'前'运算符,但如果有人给我看一个我不会感到惊讶。 :)
另一种方式是我认为的数组函数...可能涉及'< =>'我从未使用过的算子
答案 0 :(得分:2)
也许是这样的? (另):
selected_files = Dir.glob("*.pdf").select do |file|
mtime = File.mtime(file)
# if in a rails environment:
# (1.day.ago .. Time.now).cover?(mtime)
# if not in rails environment but want to use that code do this before that line:
# require 'active_support/all'
# else do the math:
# mtime > (Time.now - 86400) and mtime < Time.now
end