mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* golf_prelude.rb: find words with underscore.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									f610abc0a6
								
							
						
					
					
						commit
						84e02c8718
					
				
					 1 changed files with 4 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -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
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue