2011-10-29 48 views

回答

1
~$ ri 

Enter the method name you want to look up. 
You can use tab to autocomplete. 
Enter a blank line to exit. 

>> to_s 

= .to_s 

(from gem actionpack-3.1.0.rc6) 
=== Implementation from ActionDispatch::RemoteIp::RemoteIpGetter 
------------------------------------------------------------------------------ 
    to_s() 

------------------------------------------------------------------------------ 


(from gem actionpack-3.1.0.rc6) 
=== Implementation from ActionView::FileSystemResolver 
------------------------------------------------------------------------------ 
    to_s() 

------------------------------------------------------------------------------ 


(from gem actionpack-3.1.0.rc6) 
=== Implementation from ActionView::FixtureResolver 
------------------------------------------------------------------------------ 
    to_s() 
1

編輯|從你編輯你的問題開始,這個答案就沒有意義了;)不在上下文中。

非常無效的方法。我不明白你爲什麼會需要這個,個人的看法:

class ClassEnumerator 
    def each(&block) 
    ObjectSpace.each_object(Class, &block) 
    end 

    include Enumerable 
end 

ClassEnumerator.new.select { |klass| klass.instance_methods.include?(:merge) } 

這應該找到實現#merge所有類。

pry(main)> ClassEnumerator.new.select { |klass| klass.instance_methods.include?(:merge) } 
=> [OptionParser::CompletingHash, 
OptionParser::OptionMap, 
Hash, 
Gem::Dependency, 
Psych::Omap, 
Psych::Set, 
URI::MailTo, 
URI::LDAPS, 
URI::LDAP, 
CodeRay::CaseIgnoringWordList, 
CodeRay::WordList, 
URI::HTTPS, 
URI::HTTP, 
URI::FTP, 
URI::Generic] 
pry(main)> 
0

您也可以鍵入ri METHOD_NAME看到man ri

相關問題