aboutsummaryrefslogtreecommitdiffstats
path: root/golf_prelude.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-31 00:33:40 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-31 00:33:40 +0000
commit84e02c87184ba5e7adff6e53645e4414bdc57703 (patch)
tree6e3e3d61620a655b57c448d288c3eb66c3c6bcc5 /golf_prelude.rb
parentf610abc0a6e2ac60f6bcb7756a42e755db48a260 (diff)
downloadruby-84e02c87184ba5e7adff6e53645e4414bdc57703.tar.gz
* golf_prelude.rb: find words with underscore.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'golf_prelude.rb')
-rw-r--r--golf_prelude.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/golf_prelude.rb b/golf_prelude.rb
index 9cecd31961..114e7dba5b 100644
--- a/golf_prelude.rb
+++ b/golf_prelude.rb
@@ -3,7 +3,10 @@ SCRIPT_LINES__={}
class Object
@@golf_hash = {}
def method_missing m, *a, &b
- t = @@golf_hash[[m,self.class]] ||= (methods + private_methods).sort.find{|e|/^#{m}/=~e}
+ t = @@golf_hash.fetch(k = [m,self.class]) do
+ r = /^#{m.to_s.gsub(/(?<=\w)(?=_)/, '\w*?')}/
+ @@golf_hash[k] = (methods + private_methods).sort.find{|e|r=~e}
+ end
t ? __send__(t, *a, &b) : super
end