r/learnruby • u/hirolau • Jan 23 '13
Saving files in memory?
I have some code that creates a file on disc, emails it and then removes it. I just feel there should be no reason to write it to the disk.
Is there anyway to save the file in memory?
temp_file = 'path/to/file.csv'
users = [a@b.c, c@b.a]
CSV.open(temp_file, "w") do |csv|
csv << data_for_report
end
Reports.sendreport users temp_file
File.delete(temp_file)
0
Upvotes
View all comments
Show parent comment
1
u/hirolau Jan 24 '13
No, the "Reports.sendreport users temp_file" needs a file as an argument but I dont want to write the file to disk. After the program is finished I want the file to go away...