Created
November 1, 2011 12:11
-
-
Save amatsuda/1330397 to your computer and use it in GitHub Desktop.
A sample of Ruby's method_missing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'open-uri' | |
class Http | |
def self./(url) | |
open("http://#{url}").read | |
end | |
end | |
class String | |
def com | |
self + '.com' | |
end | |
end | |
def http | |
Http | |
end | |
def method_missing(meth, *args) | |
meth.to_s | |
end | |
# p http::/google.com |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment