Dump a URL : URI « Network « Ruby






Dump a URL


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

 








Related examples in the same category

1.Parsing URLs
2.Split a URL
3.URI::HTTP.component
4.URI::MailTo.component
5.Create a URL with URI::HTTP.build
6.mailto URI parse
7.URI parse
8.Extracting All the URLs from an HTML Document
9.Get only http and https based url