Check out example codes for "A Ruby write to file example". It will help you in understanding the concepts better.
Code Example 1
# open and write to a file with ruby open('myfile.out', 'w') do |f| f.puts "Hello, world." end # an alternative approach: open('myfile.out', 'w') do |f| f << "Hello, world.\n" end
Learn ReactJs, React Native from akashmittal.com