[前][次][番号順一覧][スレッド一覧]

ruby-changes:3316

From: ko1@a...
Date: 31 Dec 2007 09:33:48 +0900
Subject: [ruby-changes:3316] nobu - Ruby:r14809 (trunk): * golf_prelude.rb: find words with underscore.

nobu	2007-12-31 09:33:40 +0900 (Mon, 31 Dec 2007)

  New Revision: 14809

  Modified files:
    trunk/golf_prelude.rb

  Log:
    * golf_prelude.rb: find words with underscore.

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/golf_prelude.rb?r1=14809&r2=14808

Index: golf_prelude.rb
===================================================================
--- golf_prelude.rb	(revision 14808)
+++ golf_prelude.rb	(revision 14809)
@@ -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
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml

[前][次][番号順一覧][スレッド一覧]