aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Library/Homebrew/extend/string.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/Library/Homebrew/extend/string.rb b/Library/Homebrew/extend/string.rb
index b2a247297..7fe47d38e 100644
--- a/Library/Homebrew/extend/string.rb
+++ b/Library/Homebrew/extend/string.rb
@@ -24,6 +24,15 @@ class String
end
end unless method_defined?(:start_with?)
+ def end_with?(*suffixes)
+ suffixes.any? do |suffix|
+ if suffix.respond_to?(:to_str)
+ suffix = suffix.to_str
+ self[-suffix.length, suffix.length] == suffix
+ end
+ end
+ end unless method_defined?(:end_with?)
+
# String.chomp, but if result is empty: returns nil instead.
# Allows `chuzzle || foo` short-circuits.
def chuzzle