aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/extend/string.rb12
1 files changed, 7 insertions, 5 deletions
diff --git a/Library/Homebrew/extend/string.rb b/Library/Homebrew/extend/string.rb
index 1b3c1403e..b2a247297 100644
--- a/Library/Homebrew/extend/string.rb
+++ b/Library/Homebrew/extend/string.rb
@@ -15,12 +15,14 @@ class String
# EOS
alias_method :undent_________________________________________________________72, :undent
- unless String.method_defined?(:start_with?)
- def start_with? prefix
- prefix = prefix.to_s
- self[0, prefix.length] == prefix
+ def start_with?(*prefixes)
+ prefixes.any? do |prefix|
+ if prefix.respond_to?(:to_str)
+ prefix = prefix.to_str
+ self[0, prefix.length] == prefix
+ end
end
- end
+ end unless method_defined?(:start_with?)
# String.chomp, but if result is empty: returns nil instead.
# Allows `chuzzle || foo` short-circuits.