I have a function which prosecces first N files in the direcory:
def restore(cnt)
$LOG.debug "store_engine : restore tweets from cache (cnt = #{cnt})"
result = TweetCollection.new
Dir["cache/*"].each do |path|
cnt = cnt - 1
File.open(path) do |f|
result.append(Tweet.construct(:friends, :yaml, f.read))
end
if cnt == 0
return result
end
end
result
end
I'm just wondering if there is a more ruby-way method to write this function?