lib/httpx/extensions.rb in httpx-0.18.7 vs lib/httpx/extensions.rb in httpx-0.19.0
- old
+ new
@@ -52,9 +52,25 @@
end
end
Numeric.__send__(:include, NegMethods)
end
+ module StringExtensions
+ refine String do
+ def delete_suffix!(suffix)
+ suffix = Backports.coerce_to_str(suffix)
+ chomp! if frozen?
+ len = suffix.length
+ if len > 0 && index(suffix, -len)
+ self[-len..-1] = ''
+ self
+ else
+ nil
+ end
+ end unless String.method_defined?(:delete_suffix!)
+ end
+ end
+
module HashExtensions
refine Hash do
def compact
h = {}
each do |key, value|