i have a text file called text.txt with stored text like so
713,socks,3.99
888,hat,12.99
634,shirt,7.99
I want to open my file and choose a item number then i want to update the description and price. and save that back to the file.
heres my code so far
puts "Whats's the item number of the product you wish to update?"
item_num = gets.chomp
puts 'Enter new products description. '
new_description = gets.chomp
puts 'Enter new products price. '
new_price = gets.chomp.to_s
open('text.txt', 'r+') { |update|
update.puts "#{item_num},#{new_description},#{new_price}"
}
end
all this is doing is adding a new product with the same item number.