Constants
Name | Description | |
---|---|---|
COMPONENT | = [ :scheme, :userinfo, :host, :port, :registry, :path, :opaque, :query, :fragment | |
DEFAULT_PORT | = nil | |
USE_REGISTRY | = false |
Attributes
Name | Visibility | R/W | Description |
---|---|---|---|
fragment | public | R | |
host | public | R | |
opaque | public | R | |
path | public | R | |
port | public | R | |
query | public | R | |
registry | public | R | |
scheme | public | R |
Methods
Class
Visibility | Signature |
---|---|
public | build (args) |
public | build2 (args) |
public | component () |
public | default_port () |
public | new (scheme, userinfo, host, port, registry, path, opaque, query, fragment, arg_check = false) |
public | use_registry () |
Instance
Visibility | Signature |
---|---|
public | + (oth) |
public | - (oth) |
public | == (oth) |
public | absolute () |
public | absolute? () |
public | coerce (oth) |
public | component () |
public | default_port () |
public | eql? (oth) |
public | find_proxy () |
public | fragment= (v) |
public | hash () |
public | hierarchical? () |
public | host= (v) |
public | inspect () |
public | merge (oth) |
public | merge! (oth) |
public | normalize () |
public | normalize! () |
public | opaque= (v) |
public | password () |
public | password= (password) |
public | path= (v) |
public | port= (v) |
public | query= (v) |
public | registry= (v) |
public | relative? () |
public | route_from (oth) |
public | route_to (oth) |
public | scheme= (v) |
public | select (*components) |
public | to_s () |
public | user () |
public | user= (user) |
public | userinfo () |
public | userinfo= (userinfo) |
protected | component_ary () |
protected | set_fragment (v) |
protected | set_host (v) |
protected | set_opaque (v) |
protected | set_password (v) |
protected | set_path (v) |
protected | set_port (v) |
protected | set_query (v) |
protected | set_registry (v) |
protected | set_scheme (v) |
protected | set_user (v) |
protected | set_userinfo (user, password = nil) |
Class Method Detail
build(args)
Synopsis
See new
Description
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.
build2(args)
Synopsis
See new
Description
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.
component()
Components of the URI in the order.
default_port()
Returns default port
new(scheme, userinfo, host, port, registry, path, opaque, query, fragment, arg_check = false)
Args
scheme: | Protocol scheme, i.e. ‘http’,’ftp’,’mailto’ and so on. |
userinfo: | User name and password, i.e. ‘sdmitry:bla‘ |
host: | Server host name |
port: | Server port |
registry: | DOC: FIXME! |
path: | Path on server |
opaque: | DOC: FIXME! |
query: | Query data |
fragment: | A part of URI after ’#’ sign |
arg_check: | Check arguments [false by default] |
Description
Creates a new URI::Generic instance from ``generic’’ components without check.
use_registry()
DOC: FIXME!
Instance Method Detail
+(oth)
Alias for merge
-(oth)
Alias for route_from
==(oth)
Compares to URI‘s
absolute()
Alias for absolute?
absolute?()
coerce(oth)
component()
default_port()
eql?(oth)
find_proxy()
returns a proxy URI. The proxy URI is obtained from environment variables such as http_proxy, ftp_proxy, no_proxy, etc. If there is no proper proxy, nil is returned.
Note that capitalized variables (HTTP_PROXY, FTP_PROXY, NO_PROXY, etc.) are examined too.
But http_proxy and HTTP_PROXY is treated specially under CGI environment. It‘s because HTTP_PROXY may be set by Proxy: header. So HTTP_PROXY is not used. http_proxy is not used too if the variable is case insensitive. CGI_HTTP_PROXY can be used instead.
fragment=(v)
hash()
hierarchical?()
Checks if URI has a path
host=(v)
inspect()
merge(oth)
Args
oth: | URI or String |
Description
Merges two URI‘s.
Usage
require 'uri' uri = URI.parse("http://my.example.com") p uri.merge("/main.rbx?page=1") # => #<URI::HTTP:0x2021f3b0 URL:http://my.example.com/main.rbx?page=1>
merge!(oth)
Args
oth: | URI or String |
Description
Destructive form of merge
Usage
require 'uri' uri = URI.parse("http://my.example.com") uri.merge!("/main.rbx?page=1") p uri # => #<URI::HTTP:0x2021f3b0 URL:http://my.example.com/main.rbx?page=1>
normalize()
Returns normalized URI
normalize!()
Destructive version of normalize
opaque=(v)
password()
password=(password)
path=(v)
port=(v)
query=(v)
registry=(v)
relative?()
Checks if URI is relative
route_from(oth)
Args
oth: | URI or String |
Description
Calculates relative path from oth to self
Usage
require 'uri' uri = URI.parse('http://my.example.com/main.rbx?page=1') p uri.route_from('http://my.example.com') #=> #<URI::Generic:0x20218858 URL:/main.rbx?page=1>
route_to(oth)
Args
oth: | URI or String |
Description
Calculates relative path to oth from self
Usage
require 'uri' uri = URI.parse('http://my.example.com') p uri.route_to('http://my.example.com/main.rbx?page=1') #=> #<URI::Generic:0x2020c2f6 URL:/main.rbx?page=1>
scheme=(v)
select(*components)
Args
components: | Multiple Symbol arguments defined in URI::HTTP |
Description
Selects specified components from URI
Usage
require 'uri' uri = URI.parse('http://myuser:mypass@my.example.com/test.rbx') p uri.select(:userinfo, :host, :path) # => ["myuser:mypass", "my.example.com", "/test.rbx"]
to_s()
user()
user=(user)
userinfo()
userinfo=(userinfo)
Sets userinfo, argument is string like ‘name:pass‘