Chris Daves wrote:
bold italic underline superscript
i cant find out how to read in the file. where should i save the text
file on the computer? and where will the new file appear?
Look at the doc for the File class and the IO class. File inherits from
IO so all the methods in IO are available in File.
You can save the text file anywhere. When you open the file for reading
you have to tell Ruby - actually the File.open method - where it is. For
example if you save the file in “C:\My Documents\references.txt” then
you have to tell File.open to open “C:\My Documents\references.txt”.
File.open can open any disk file, as long as you tell it which one to
“Standard output” is the console by default, so since you’re writing the
new file to standard output, the new file will appear on your console
unless you redirect standard output to a file, in which case the new
file will appear where ever you redirected standard output. Redirecting
is a function of the command processor or shell, not Ruby. Typically you
redirect standard output by using “>filename” on the command line. For
example, the following command redirects standard output to a file
called "myoutput.txt in the current directory:
ruby mypgm.rb >myoutput.txt
Ruby uses special variables to that represent standard output and
standard error. See the doc on $stdout and $stderr.