【发布时间】:2014-02-23 11:15:51
【问题描述】:
我有一个包含文件的文件夹。我想知道如果文件夹中的每个 .txt 文件都包含“BREAK”一词,我该如何检查它。我知道这一定很容易,但我有点怀念完成它的方式。
这是我迄今为止尝试过的
Dir.glob('/path/to/dir/*.txt') do |txt_file|
# And here I need a method that opens the 'txt_file'
# and checks if it contains "BREAK"
end
【问题讨论】: