Skip to content

Commit

Permalink
* golf_prelude.rb: find words with underscore.
Browse files Browse the repository at this point in the history
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 84e02c8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion golf_prelude.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 84e02c8

Please sign in to comment.