Skip to content

Instantly share code, notes, and snippets.

@jqr
Created April 2, 2009 21:23
Show Gist options
  • Save jqr/89498 to your computer and use it in GitHub Desktop.
Save jqr/89498 to your computer and use it in GitHub Desktop.
def reindent(data, base)
lines = data.split("\n")
smallest_indentation = lines.collect { |l| l =~ /\w/ }.min
lines.each do |line|
line.gsub!(/^\s{#{smallest_indentation}}/, ' ' * base)
end
lines.join("\n")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment