Sha256: 231363e9918c31c3d6b8a59f583c1d553105aa333a62857c34a3d996f6faf8e0
Contents?: true
Size: 594 Bytes
Versions: 24
Compression:
Stored size: 594 Bytes
Contents
class String # Strips indentation in heredocs. # # For example in # # if options[:usage] # puts <<-USAGE.strip_heredoc # This command does such and such. # # Supported options are: # -h This message # ... # USAGE # end # # the user would see the usage message aligned against the left margin. # # Technically, it looks for the least indented non-empty line # in the whole string, and removes that amount of leading whitespace. def strip_heredoc gsub(/^#{scan(/^[ \t]*(?=\S)/).min}/, "".freeze) end end
Version data entries
24 entries across 24 versions & 4 rubygems