I have compiled the user's answers into a .TXT file and move it to another location, where I would store all the answers. I would need that .TXT to be named differently each time a user runs the application, so that the file is not replaced. I thought about appending time stamps next to the original name, but not sure how to do that.
My code:
require 'FileUtils'
puts "1) How would you rate the manual? Range: 1-10."
rating_range = gets.to_i
puts "2) How could the manual be improved? Type your answer below:"
improvement = gets.chomp
puts "3) What would you add to the manual. Type your answer below:"
addition = gets.chomp
puts "4) Indicate any general comments you would like to add:"
general_comments = gets.chomp
File.open("Survey.txt", 'w') { |file|
file << "1) #{rating_range}\n"
file << "2) #{improvement}\n"
file << "3) #{addition}\n"
file << "4) #{general_comments}\n"
}
FileUtils.mv('/Documents/Survey.txt', '/Stuff')
The file Survey.txt
should be named differently each time.
Any ideas?