uri.rb is a package for parse URI text string. It conforms RFC 2396 basically. Now it supports only tow schemes, FTP and HTTP.
URI is a abstract class. But it has common interface to instantiate an URI object.
To instanciate ALL kinds of URI objects, use URI.create. DO NOT use new() directlly to instanciate HTTPURL or others.
To escape query string, use URI#escape. (Thanx NaHi, Wakou)
Getter methods return a component string that is not dup-ed and not freeze-ed.
creates an URI object from URI text string
If you want to get an URI objects, use this method. DO NOT instanciate HTTPURL or others directlly.
Now, URI creates only two kinds of objects, FTPURL and HTTPURL
precond: absolute_uri and ((relative_uri.nil? and absolute_uri.is_a? String) or (relative_uri.is_a? String and (absolute_uri.is_a? String or absolute_uri.is_a? URI))) postcond: const absolute_uri, const relative_uri return: aURI raise: URIError if absolute_uri and/or relative_uri are a bad URI
escapes query string. You had better use cgi.rb
unescape query string.
returns URI component specified by
component_name
Iterats over each `component name' and `component' pair like Hash#each.
returns `scheme' component.
return: aString, (aString != nil)
Returns true if self.type == obj.type. Or if obj
is a
String, an URI object is instanciated then it is compared with
self.
duplicates self.
GenericURI is a abstract class. Its super class is URI. Its subclasses are FTPURL, HTTPURL and etc.
A instance of subclass which are subclassed from GenericURI may have scheme, userinfo, host, port, path, query, and fragment.
create_relative_uri is a instance method to create another URI instance relative to the receiver.
create relative URI to self.
raise: URIError if relative_url is not URL text string.
returns `host' component.
return: aString (aString != nil)
setter for `host' component.
returns `path' component.
return: aString (aString != nil and aString[0] == ?/)
setters for `path' component.
returns `port' component.
return: aString (/\A\d+\z/ =~ aString)
setter for `port' component.
raise: URIError if /^\d+$/ !~ port.to_s
returns `query' component.
return: nil or aString (does not start with '?' basically)
setter for `query' component.
returns `fragment' component.
return: nil or aString (does not start with '#' basically)
setter for `fragment' component.
returns `userinfo' component.
return: nil or aString
setter for `userinfo' component.
compares to obj
. Although `fragment' component is
not a part of URI, this method compare `fragment' components of self
and obj. `host' components are compared case-insensitive. Most
components are escaped when they are compared. See RFC for detail.
returns URI text string
FTPURL is a class for FTP URL scheme.
A String, `21'
returns `user' component.
return: nil or aString
returns `password' component.
return: nil or aString
setter for `password' component.
returns `type' component (Object has type method).
return: nil or aString (/\A[aid]\z/ =~ aString)
setter for `type' component.
raise: URIError if /^[aid]$/ !~ typecode
HTTPURL is a class for HTTP URL scheme.
A String, `80'.
2000.07.17
greentea@fa2.so-net.ne.jp