Skip to content

Instantly share code, notes, and snippets.

@tex2e
Created March 21, 2016 12:53
Show Gist options
  • Save tex2e/1bcbe96c2a1fd5570d20 to your computer and use it in GitHub Desktop.
Save tex2e/1bcbe96c2a1fd5570d20 to your computer and use it in GitHub Desktop.
strip indentation for Ruby heredoc
# strip indentation
class String
def dedent
margin = self.scan(/^ +/).map(&:size).min
self.gsub(/^ {#{margin}}/, '')
end
end
def usage
puts <<-EOS.dedent
Overview:
foo bar baz
Usage:
foo <spam> <ham> <eggs...>
EOS
exit
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment