Skip to content

Instantly share code, notes, and snippets.

@quackingduck
Created February 4, 2009 07:54
Show Gist options
  • Save quackingduck/58009 to your computer and use it in GitHub Desktop.
Save quackingduck/58009 to your computer and use it in GitHub Desktop.
# removes leading indentation, sometimes nicer than using a heredoc
def clip(str)
return str unless str.include?("\n")
first_indent = str.match(/\n\s*/).to_s
str.gsub( first_indent, "\n" ).strip
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment