1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

golf_prelude.rb: suppress the redefining warning

This commit is contained in:
Nobuyoshi Nakada 2019-06-22 23:38:07 +09:00
parent bad66f3e36
commit f738eeabc2
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60

View file

@ -1,6 +1,7 @@
class Object
@@golf_hash = {}
verbose, $VERBOSE = $VERBOSE, nil
def method_missing m, *a, &b
t = @@golf_hash[ [m, self.class] ] ||= matching_methods(m)[0]
if t && b
@ -12,6 +13,7 @@ class Object
t ? __send__(t, *a, &b) : super
end
end
$VERBOSE = verbose
def matching_methods(s = '', m = callable_methods)
r = /^#{s.to_s.gsub(/./){"(.*?)" + Regexp.escape($&)}}/