This class represents a URI reference as defined by [RFC 3986: Uniform Resource Identifier (URI): Generic Syntax](https://www.ietf.org/rfc/rfc3986.txt).
This class provides constructors for creating URI instances from their components or by parsing their string forms and methods for accessing the various components of an instance.
Basic example:
require "uri"
uri = URI.parse "http://foo.com/posts?id=30&limit=5#time=1305298413"
# => #<URI:0x1003f1e40 @scheme="http", @host="foo.com", @port=nil, @path="/posts", @query="id=30&limit=5", ... >
uri.scheme
# => "http"
uri.host
# => "foo.com"
uri.query
# => "id=30&limit=5"
uri.to_s
# => "http://foo.com/posts?id=30&limit=5#time=1305298413"
/\\A(?<relative_ref>(?<relative_part>\\/\\/(?<authority>(?:(?<userinfo>(?:%\\h\\h|[!$&-.0-;=A-Z_a-z~])*)@)?(?<host>(?<IP_literal>\\[(?<IPv6address>(?:\\h{1,4}:){6}(?<ls32>\\h{1,4}:\\h{1,4}|(?<IPv4address>(?<dec_octet>[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5]|\\d)\\.\\g<dec_octet>\\.\\g<dec_octet>\\.\\g<dec_octet>))|::(?:\\h{1,4}:){5}\\g<ls32>|\\h{1,4}?::(?:\\h{1,4}:){4}\\g<ls32>|(?:(?:\\h{1,4}:){,1}\\h{1,4})?::(?:\\h{1,4}:){3}\\g<ls32>|(?:(?:\\h{1,4}:){,2}\\h{1,4})?::(?:\\h{1,4}:){2}\\g<ls32>|(?:(?:\\h{1,4}:){,3}\\h{1,4})?::\\h{1,4}:\\g<ls32>|(?:(?:\\h{1,4}:){,4}\\h{1,4})?::\\g<ls32>|(?:(?:\\h{1,4}:){,5}\\h{1,4})?::\\h{1,4}|(?:(?:\\h{1,4}:){,6}\\h{1,4})?::)|(?<IPvFuture>v\\h+\\.[!$&-.0-;=A-Z_a-z~]+)\\])|\\g<IPv4address>|(?<reg_name>(?:%\\h\\h|[!$&-.0-9;=A-Z_a-z~])+))?(?::(?<port>\\d*))?)(?<path_abempty>(?:\\/(?<segment>(?:%\\h\\h|[!$&-.0-;=@-Z_a-z~])*))*)|(?<path_absolute>\\/(?:(?<segment_nz>(?:%\\h\\h|[!$&-.0-;=@-Z_a-z~])+)(?:\\/\\g<segment>)*)?)|(?<path_noscheme>(?<segment_nz_nc>(?:%\\h\\h|[!$&-.0-9;=@-Z_a-z~])+)(?:\\/\\g<segment>)*)|(?<path_empty>))(?:\\?(?<query>[^#]*))?(?:\\#(?<fragment>(?:%\\h\\h|[!$&-.0-;=@-Z_a-z~\\/?])*))?)\\z/
/\\A(?<URI>(?<scheme>[A-Za-z][+\\-.0-9A-Za-z]*):(?<hier_part>\\/\\/(?<authority>(?:(?<userinfo>(?:%\\h\\h|[!$&-.0-;=A-Z_a-z~])*)@)?(?<host>(?<IP_literal>\\[(?:(?<IPv6address>(?:\\h{1,4}:){6}(?<ls32>\\h{1,4}:\\h{1,4}|(?<IPv4address>(?<dec_octet>[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5]|\\d)\\.\\g<dec_octet>\\.\\g<dec_octet>\\.\\g<dec_octet>))|::(?:\\h{1,4}:){5}\\g<ls32>|\\h{1,4}?::(?:\\h{1,4}:){4}\\g<ls32>|(?:(?:\\h{1,4}:)?\\h{1,4})?::(?:\\h{1,4}:){3}\\g<ls32>|(?:(?:\\h{1,4}:){,2}\\h{1,4})?::(?:\\h{1,4}:){2}\\g<ls32>|(?:(?:\\h{1,4}:){,3}\\h{1,4})?::\\h{1,4}:\\g<ls32>|(?:(?:\\h{1,4}:){,4}\\h{1,4})?::\\g<ls32>|(?:(?:\\h{1,4}:){,5}\\h{1,4})?::\\h{1,4}|(?:(?:\\h{1,4}:){,6}\\h{1,4})?::)|(?<IPvFuture>v\\h+\\.[!$&-.0-;=A-Z_a-z~]+))\\])|\\g<IPv4address>|(?<reg_name>(?:%\\h\\h|[!$&-.0-9;=A-Z_a-z~])+))?(?::(?<port>\\d*))?)(?<path_abempty>(?:\\/(?<segment>(?:%\\h\\h|[!$&-.0-;=@-Z_a-z~])*))*)|(?<path_absolute>\\/(?:(?<segment_nz>(?:%\\h\\h|[!$&-.0-;=@-Z_a-z~])+)(?:\\/\\g<segment>)*)?)|(?<path_rootless>\\g<segment_nz>(?:\\/\\g<segment>)*)|(?<path_empty>))(?:\\?(?<query>[^#]*))?(?:\\#(?<fragment>(?:%\\h\\h|[!$&-.0-;=@-Z_a-z~\\/?])*))?)\\z/
URI defined in RFC3986
Parses raw_url into an URI.
Returns the fragment component of the URI.
Sets the fragment component of the URI.
Returns the full path of this URI.
Returns the host component of the URI.
Sets the host component of the URI.
Returns the opaque component of the URI.
Sets the opaque component of the URI.
Returns the password component of the URI.
Sets the password component of the URI.
Returns the path component of the URI.
Sets the path component of the URI.
Returns the port component of the URI.
Sets the port component of the URI.
Returns the query component of the URI.
Sets the query component of the URI.
Returns the scheme component of the URI.
Sets the scheme component of the URI.
Returns the user component of the URI.
Sets the user component of the URI.
Returns the user-information component containing the provided username and password.
Parses raw_url into an URI. The raw_url may be relative or absolute.
require Returns the fragment component of the URI.
URI.parse("http://foo.com/bar#section1").fragment # => "section1"Sets the fragment component of the URI.
Returns the full path of this URI.
uri = URI.parse "http://foo.com/posts?id=30&limit=5#time=1305298413"
uri.full_path # => "/posts?id=30&limit=5"Returns the host component of the URI.
URI.parse("http://foo.com").host # => "foo.com"Sets the host component of the URI.
Returns the opaque component of the URI.
URI.parse("mailto:alice@example.com").opaque # => "alice@example.com"Sets the opaque component of the URI.
Returns the password component of the URI.
URI.parse("http://admin:password@foo.com").password # => "password"Sets the password component of the URI.
Returns the path component of the URI.
URI.parse("http://foo.com/bar").path # => "/bar"Sets the path component of the URI.
Returns the port component of the URI.
URI.parse("http://foo.com:5432").port # => 5432Sets the port component of the URI.
Returns the query component of the URI.
URI.parse("http://foo.com/bar?q=1").query # => "q=1"Sets the query component of the URI.
Returns the scheme component of the URI.
URI.parse("http://foo.com").scheme # => "http"
URI.parse("mailto:alice@example.com").scheme # => "mailto"Sets the scheme component of the URI.
Returns the user component of the URI.
URI.parse("http://admin:password@foo.com").user # => "admin"Sets the user component of the URI.
Returns the user-information component containing the provided username and password.
uri = URI.parse "http://admin:password@foo.com"
uri.userinfo # => "admin:password"