new(scheme, userinfo, host, port, registry, path, opaque, query, fragment, parser = DEFAULT_PARSER, arg_check = false)
public
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 |
Registry of naming authorities.
|
path |
Path on server
|
opaque |
Opaque part
|
query |
Query data
|
fragment |
A part of URI after ‘#’ sign
|
parser |
Parser for internal use [URI::DEFAULT_PARSER by default]
|
arg_check |
Check arguments [false by default]
|
Description
Creates a new URI::Generic instance from “generic”
components without check.
Show source
def initialize(scheme,
userinfo, host, port, registry,
path, opaque,
query,
fragment,
parser = DEFAULT_PARSER,
arg_check = false)
@scheme = nil
@user = nil
@password = nil
@host = nil
@port = nil
@path = nil
@query = nil
@opaque = nil
@registry = nil
@fragment = nil
@parser = parser == DEFAULT_PARSER ? nil : parser
if arg_check
self.scheme = scheme
self.userinfo = userinfo
self.hostname = host
self.port = port
self.path = path
self.query = query
self.opaque = opaque
self.registry = registry
self.fragment = fragment
else
self.set_scheme(scheme)
self.set_userinfo(userinfo)
self.set_host(host)
self.set_port(port)
self.set_path(path)
self.set_query(query)
self.set_opaque(opaque)
self.set_registry(registry)
self.set_fragment(fragment)
end
if @registry && !self.class.use_registry
raise InvalidURIError,
"the scheme #{@scheme} does not accept registry part: #{@registry} (or bad hostname?)"
end
@scheme.freeze if @scheme
self.set_path('') if !@path && !@opaque
self.set_port(self.default_port) if self.default_port && !@port
end