aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/extend/string.rb
blob: 974906b1d2c093d1fdd75fafdee9ad80d2c8b266 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class String
  def undent
    gsub /^.{#{slice(/^ +/).length}}/, ''
  end
end

if __FILE__ == $0
  undented = <<-EOS.undent
    hi
....my friend over
    there
  EOS
  
  assert undented == "hi\nmy friend over\nthere\n"
end