Adding a <br /> tag before each newline is accomplished in Ruby using string
substitution with String#gsub.
{{code:php
$result = nl2br("The quick\nbrown fox");
var_export($result);
// => "The quick
\nbrown fox"
}}
{{code:ruby
p "The quick\nbrown fox".gsub("\n", "
\n")
# => "The quick
\nbrown fox"
}}
{{related: strings/htmlentities strings/htmlspecialchars strings/wordwrap strings/str_replace }}