Constants
DEFAULT_PORT = nil
COMPONENT = [ :scheme, :userinfo, :host, :port, :registry, :path, :opaque, :query, :fragment ].freeze
USE_REGISTRY = false
Attributes
[R] | scheme |
returns the scheme component of the URI. URI("http://foo/bar/baz").scheme #=> "http" |
[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] | port |
returns the port component of the URI. URI("http://foo/bar/baz").port #=> "80" URI("http://foo:8080/bar/baz").port #=> "8080" |
[R] | registry |
returns the registry component of the URI. (see RFC2396 Section 3.2) |
[R] | path |
returns the path component of the URI. URI("http://foo/bar/baz").path #=> "/bar/baz" |
[R] | query |
returns the query component of the URI. URI("http://foo/bar/baz?search=FooBar").query #=> "search=FooBar" |
[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] | fragment |
returns the fragment component of the URI. URI("http://foo/bar/baz?search=FooBar#ponies").fragment #=> "ponies" |