Permalink
Browse files

* golf_prelude.rb: find words with underscore.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information...
nobu committed Dec 31, 2007
1 parent f610abc commit 84e02c87184ba5e7adff6e53645e4414bdc57703
Showing with 4 additions and 1 deletion.
  1. +4 −1 golf_prelude.rb
View
@@ -3,7 +3,10 @@
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

0 comments on commit 84e02c8

Please sign in to comment.