back-port start_with? from 1.8.7

This allows its use in Leopard, which has Ruby 1.8.6.
This commit is contained in:
Adam Vandenberg 2011-06-13 13:02:17 -07:00
parent 0d44609dfb
commit e6bac8a8ea

View File

@ -2,6 +2,13 @@ class String
def undent def undent
gsub(/^.{#{slice(/^ +/).length}}/, '') gsub(/^.{#{slice(/^ +/).length}}/, '')
end end
unless String.method_defined?(:start_with?)
def start_with? prefix
prefix = prefix.to_s
self[0, prefix.length] == prefix
end
end
end end
# used by the inreplace function (in utils.rb) # used by the inreplace function (in utils.rb)