require 'uri'
class URI::Generic
def dump
component.each do |m|
puts "#{m}: #{send(m).inspect}"
end
end
end
url = 'http://l:pw@www.subdomain.example.com:6060' +
'/cgi-bin/mycgi.cgi?key1=val1#anchor'
URI.parse(url).dump
URI::parse('ftp://l:password@ftp.example.com/file.txt').dump