Sha256: f2b464ec8815b910146374337790a66c24330cdd2bd077caa8a9aa978532184a
Contents?: true
Size: 623 Bytes
Versions: 33
Compression:
Stored size: 623 Bytes
Contents
# String 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 line in the whole string, and removes # that amount of leading whitespace. def strip_heredoc indent = scan(/^[ \t]*(?=\S)/).min.to_s.size gsub(/^[ \t]{#{indent}}/, '') end end
Version data entries
33 entries across 33 versions & 3 rubygems