Components of the URI in the order.
See new
At first, tries to create a new URI::Generic instance using URI::Generic::build. But, if exception URI::InvalidComponentError is raised, then it URI::Escape.escape all URI components and tries again.
See new
Creates a new URI::Generic instance from components of URI::Generic with check. Components are: scheme, userinfo, host, port, registry, path, opaque, query and fragment. You can provide arguments either by an Array or a Hash. See new for hash keys to use or for order of array items.
schemeProtocol scheme, i.e. ‘http’,‘ftp’,‘mailto’ and so on.
userinfoUser name and password, i.e. ‘sdmitry:bla’
hostServer host name
portServer port
registryRegistry of naming authorities.
pathPath on server
opaqueOpaque part
queryQuery data
fragmentA part of URI after ‘#’ sign
parserParser for internal use [URI::DEFAULT_PARSER by default]
arg_checkCheck arguments [false by default]
Creates a new URI::Generic instance from “generic” components without check.
returns the parser to be used.
Unless a URI::Parser is defined, then DEFAULT_PARSER is used.
replace self by other URI object
Components of the URI in the order.
vString
public setter for the scheme component v. (with validation)
see also URI::Generic.check_scheme
require 'uri' uri = URI.parse("http://my.example.com") uri.scheme = "https" # => "https" uri #=> #<URI::HTTP:0x000000008e89e8 URL:https://my.example.com>
vString
public setter for the user component. (with validation)
see also URI::Generic.check_user
require 'uri' uri = URI.parse("http://john:S3nsit1ve@my.example.com") uri.user = "sam" # => "sam" uri #=> #<URI::HTTP:0x00000000881d90 URL:http://sam:V3ry_S3nsit1ve@my.example.com>
vString
public setter for the password component. (with validation)
see also URI::Generic.check_password
require 'uri' uri = URI.parse("http://john:S3nsit1ve@my.example.com") uri.password = "V3ry_S3nsit1ve" # => "V3ry_S3nsit1ve" uri #=> #<URI::HTTP:0x00000000881d90 URL:http://john:V3ry_S3nsit1ve@my.example.com>
returns the user component
returns the password component
vString
public setter for the host component v. (with validation)
see also URI::Generic.check_host
require 'uri' uri = URI.parse("http://my.example.com") uri.host = "foo.com" # => "foo.com" uri #=> #<URI::HTTP:0x000000008e89e8 URL:http://foo.com>
extract the host part of the URI and unwrap brackets for IPv6 addresses.
This method is same as URI::Generic#host except brackets for IPv6 (and future IP) addresses are removed.
u = URI("http://[::1]/bar") p u.hostname #=> "::1" p u.host #=> "[::1]"
set the host part of the URI as the argument with brackets for IPv6 addresses.
This method is same as URI::Generic#host= except the argument can be bare IPv6 address.
u = URI("http://foo/bar") p u.to_s #=> "http://foo/bar" u.hostname = "::1" p u.to_s #=> "http://[::1]/bar"
If the argument seems IPv6 address, it is wrapped by brackets.
vString
public setter for the port component v. (with validation)
see also URI::Generic.check_port
require 'uri' uri = URI.parse("http://my.example.com") uri.port = 8080 # => 8080 uri #=> #<URI::HTTP:0x000000008e89e8 URL:http://my.example.com:8080>
vString
public setter for the path component v. (with validation)
see also URI::Generic.check_path
require 'uri' uri = URI.parse("http://my.example.com/pub/files") uri.path = "/faq/" # => "/faq/" uri #=> #<URI::HTTP:0x000000008e89e8 URL:http://my.example.com/faq/>
vString
public setter for the query component v.
require 'uri' uri = URI.parse("http://my.example.com/?id=25") uri.query = "id=1" # => "id=1" uri #=> #<URI::HTTP:0x000000008e89e8 URL:http://my.example.com/?id=1>
vString
public setter for the opaque component v. (with validation)
see also URI::Generic.check_opaque
check the fragment v component against the URI::Parser Regexp for :FRAGMENT
vString
public setter for the fragment component v. (with validation)
require 'uri' uri = URI.parse("http://my.example.com/?id=25#time=1305212049") uri.fragment = "time=1305212086" # => "time=1305212086" uri #=> #<URI::HTTP:0x000000007a81f8 URL:http://my.example.com/?id=25#time=1305212086>
Checks if URI has a path
Checks if URI is an absolute one
Checks if URI is relative