Reputation: 5603
I have a loop that goes through 100 times and puts
something to the screen. EX:
1.upto(100) { |i| puts i }
#=>1
#=>2
#=>...100
Instead of using puts
to display the result in my terminal, I need to store the result in a log file (or plain text) to send in an email to test@test.com
.
EX:
1.upto(100) do |i|
x = []
x << i
end
x.email.send(test@test.com)
Granted the above wouldn't work, that's the idea. I don't want to send 100 emails, but I want to send the result of each loop #{i}
to test@test.com
all inside one email. Is there a gem or easy way to manage this?
Upvotes: 1
Views: 66
Reputation: 118299
Are you looking for something like this?
File.open(yourfile, 'w') do |file|
(1..100).each do |num|
file.write(num)
end
end
Upvotes: 1