Base class for all URI classes. Implements generic URI syntax as per RFC 2396.

Constants

USE_REGISTRY = false

COMPONENT = [ :scheme, :userinfo, :host, :port, :registry, :path, :opaque, :query, :fragment ].freeze

DEFAULT_PORT = nil

Attributes

[R] fragment

returns the fragment component of the URI.

URI("http://foo/bar/baz?search=FooBar#ponies").fragment #=> "ponies"
[R] opaque

returns the opaque part of the URI.

URI("mailto:foo@example.org").opaque #=> "foo@example.org"

Portion of the path that does make use of the slash ‘/’. The path typically refers to the absolute path and the opaque part. (See RFC2396 Section 3 and 5.2.)

[R] query

returns the query component of the URI.

URI("http://foo/bar/baz?search=FooBar").query #=> "search=FooBar"
[R] path

returns the path component of the URI.

URI("http://foo/bar/baz").path #=> "/bar/baz"
[R] port

returns the port component of the URI.

URI("http://foo/bar/baz").port #=> "80"

URI("http://foo:8080/bar/baz").port #=> "8080"
[R] host

returns the host component of the URI.

URI("http://foo/bar/baz").host #=> "foo"

It returns nil if no host component.

URI("mailto:foo@example.org").host #=> nil

The component doesn’t contains the port number.

URI("http://foo:8080/bar/baz").host #=> "foo"

Since IPv6 addresses are wrapped by brackets in URIs, this method returns IPv6 addresses wrapped by brackets. This form is not appropriate to pass socket methods such as TCPSocket.open. If unwrapped host names are required, use “hostname” method.

URI("http://[::1]/bar/baz").host #=> "[::1]"
URI("http://[::1]/bar/baz").hostname #=> "::1"
[R] scheme

returns the scheme component of the URI.

URI("http://foo/bar/baz").scheme #=> "http"
Show files where this class is defined (1 file)
Register or log in to add new notes.