Created
August 15, 2008 23:06
-
-
Save ELLIOTTCABLE/5673 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Objects of this class are *almost* a URI! | |
class AlmostURI < String; end | |
[AlmostURI, String, Symbol].each do |klass| | |
klass.class_eval do | |
def / urlpart | |
AlmostURI.new [self, urlpart].join('/') | |
end | |
def method_missing meth, *args | |
AlmostURI.new [self, urlpart].join('.') | |
end | |
end | |
end | |
def method_missing meth, *args | |
if args.size == 1 and args.first == :/ | |
return AlmostURI.new [self, ':/'].join('.') | |
else | |
super | |
end | |
end | |
p((http://:google.com/:test.rb).to_s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment