Contents:
Synopsis
URI::parse(uri_str)
Args
| uri_str: | String with URI. |
Description
Creates one of the URI’s subclasses instance from the string.
Raises
Raised if URI given is not a correct one.
Usage
require 'uri' uri = URI.parse("http://www.ruby-lang.org/") p uri # => #<URI::HTTP:0x202281be URL:http://www.ruby-lang.org/> p uri.scheme # => "http" p uri.host # => "www.ruby-lang.org"
Source Code
# File uri/common.rb, line 483 def self.parse(uri) scheme, userinfo, host, port, registry, path, opaque, query, fragment = self.split(uri) if scheme && @@schemes.include?(scheme.upcase) @@schemes[scheme.upcase].new(scheme, userinfo, host, port, registry, path, opaque, query, fragment) else Generic.new(scheme, userinfo, host, port, registry, path, opaque, query, fragment) end end
<code/>and<pre/>for code samples.