Suppose I have a string called very_long_string whose content I want to send to the standard output. But since the string is very long, I want to use less to display the text on the terminal. When I use
`less #{very_long_string}`
I get File not found error message, and if I use:
`less <<< #{very_long_string}`
I get unexpected redirection error message.
So, how to use less from inside Ruby?
You could open a pipe and feed your string to less via its stdin.
(Assuming very_long_string is the variable holding your string.)
See: http://www.ruby-doc.org/core-1.8.7/IO.html#method-c-popen