Multiline strings with ActiveSupport
When using ActiveSupport you can easily have multiline strings with proper indentation, just use strip_heredoc like this:
if options[:usage]
puts <<-USAGE.strip_heredoc
This command does such and such.
Supported options are:
-h This message
...
USAGE
end
It looks for the least indented line in the whole string, and removes that amount of leading whitespace from each line.
Written by Pranas Kiziela
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#