Last Updated: February 25, 2016
·
969
· pranas

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.

http://apidock.com/rails/String/strip_heredoc