I need to format a String that ends with a newline. I'd just add a "\n", but I want this to work on Windows too. Many languages have a constant that provides the appropriate CR/LF/CRLF sequence according to the platform, but I can't seem to find anything in Ruby. Does it exist?
Ruby's got four (!)
p $/
p $-0
require 'English'
p $RS
p $INPUT_RECORD_SEPARATOR
Using IO#puts (= File#puts) will take care of the proper EOL, no need to set it manually.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With