aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMisty De Meo2014-03-27 10:14:08 -0700
committerMisty De Meo2014-03-27 10:14:08 -0700
commitcb1a77291419a33c7ec5b7634846e52ce4e20f55 (patch)
treef96873361331fcb72a8a18f58ab7736cc01f1be2 /Library
parent7b0cd7877310e2e7fda2bdfdfb8ac8db42151578 (diff)
downloadhomebrew-cb1a77291419a33c7ec5b7634846e52ce4e20f55.tar.bz2
extend/string: backport #rpartition
Diffstat (limited to 'Library')
-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 7fe47d38e..56126e247 100644
--- a/Library/Homebrew/extend/string.rb
+++ b/Library/Homebrew/extend/string.rb
@@ -33,6 +33,15 @@ class String
end
end unless method_defined?(:end_with?)
+ # 1.8.7 or later; used in bottle code
+ def rpartition(separator)
+ if ind = rindex(separator)
+ [slice(0, ind), separator, slice(ind+1, -1) || '']
+ else
+ ['', '', dup]
+ end
+ end unless method_defined?(:rpartition)
+
# String.chomp, but if result is empty: returns nil instead.
# Allows `chuzzle || foo` short-circuits.
def chuzzle