2012-02-29 37 views
1

如何設計一個與URI模塊類似的模塊?我的意思是這樣的:如何在Ruby中調用URI模塊

1.9.3-p125 :001 > require 'uri' 
=> true 
1.9.3-p125 :002 > URI.class 
=> Module 
1.9.3-p125 :003 > URI("http://google.com") 
=> #<URI::HTTP:0x0000010d8f6bd8 URL:http://google.com> 

回答

1

這是可能的具有相同名稱的方法和類/模塊:

1.8.7 > class Foo; end 
=> nil 
1.8.7 > def Foo; 42; end 
=> nil 
1.8.7 > Foo 
=> Foo 
1.8.7 > Foo() 
=> 42