I found this ruby problem on RubyQuiz, which states besides the problem itself, the following:
"The script should be a standard Unix filter, reading from files specified on the command-line or STDIN and writing to STDOUT. Each line of input will contain one integer (between 1 and 3999) expressed as an Arabic or Roman numeral"
I have no idea how to do a Unix Filter using Ruby.. to read files in this case,
Could somebody please enlighten me on how to accomplish this task in the best way p开发者_开发技巧ossible.
Thanks as always!
The best way to read files from STDIN is using ARGF, as explained in this answer: Best practices with STDIN in Ruby?
You can write to STDOUT using puts or printf.
For more detailed info about IO in Ruby, read the Ruby Doc: http://www.ruby-doc.org/core/classes/IO.html
精彩评论