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
Part of the URI
after ‘#’ character.
parser
Parser
for internal use [URI::DEFAULT_PARSER by default].
arg_check
Check arguments [false by default].
Creates a new URI::Generic
instance from “generic” components without check.
Creates a new URI::LDAP
object from generic URI
components as per RFC 2396. No LDAP-specific syntax checking is performed.
Arguments are scheme
, userinfo
, host
, port
, registry
, path
, opaque
, query
, and fragment
, in that order.
Example:
uri = URI::LDAP.new("ldap", nil, "ldap.example.com", nil, nil, "/dc=example;dc=com", nil, "query", nil)
See also URI::Generic.new
.
Creates a new URI::MailTo
object from generic URL components with no syntax checking.
This method is usually called from URI::parse
, which checks the validity of each component.
URI::Parser.new([opts])
The constructor accepts a hash as options for parser. Keys of options are pattern names of URI
components and values of options are pattern strings. The constructor generates set of regexps for parsing URIs.
You can use the following keys:
* :ESCAPED (URI::PATTERN::ESCAPED in default) * :UNRESERVED (URI::PATTERN::UNRESERVED in default) * :DOMLABEL (URI::PATTERN::DOMLABEL in default) * :TOPLABEL (URI::PATTERN::TOPLABEL in default) * :HOSTNAME (URI::PATTERN::HOSTNAME in default)
p = URI::Parser.new(:ESCAPED => "(?:%[a-fA-F0-9]{2}|%u[a-fA-F0-9]{4})") u = p.parse("http://example.jp/%uABCD") #=> #<URI::HTTP http://example.jp/%uABCD> URI.parse(u.to_s) #=> raises URI::InvalidURIError s = "http://example.com/ABCD" u1 = p.parse(s) #=> #<URI::HTTP http://example.com/ABCD> u2 = URI.parse(s) #=> #<URI::HTTP http://example.com/ABCD> u1 == u2 #=> true u1.eql?(u2) #=> false
Creates a new CGI
interface.
The first argument in args
is a configuration hash which would update WEBrick::Config::HTTP.
Any remaining arguments are stored in the @options
instance variable for use by a subclass.
Creates a new cookie with the given name
and value
Proxy server configurations. The proxy server handles the following configuration items in addition to those supported by HTTPServer:
Called with a request and response to authorize a request
Appended to the via header
The proxy server’s URI
Called with a request and response and allows modification of the response
Sets the proxy timeouts to 30 seconds for open and 60 seconds for read operations
Creates a new HTTP request. WEBrick::Config::HTTP is the default configuration.
Creates a new HTTP response object. WEBrick::Config::HTTP is the default configuration.
Creates a new SNIRequest
.
Creates a new HTTP server according to config
An HTTP server uses the following attributes:
An array of access logs. See WEBrick::AccessLog
Local address for the server to bind to
Root path to serve files from
Options for the default HTTPServlet::FileHandler
The HTTP version of this server
Port to listen on
Called with a request and response before each request is serviced.
Maximum time to wait between requests
Array
of alternate names for this server for virtual hosting
Name for this server for virtual hosting
Creates a new HTTPVersion
from version
.
Initializes a new logger for log_file
that outputs messages at level
or higher. log_file
can be a filename, an IO-like object that responds to <<
or nil which outputs to $stderr.
If no level is given INFO
is chosen by default
Creates a new generic server from config
. The default configuration comes from default
.
Creates a new YAML::Store
object, which will store data in file_name
. If the file does not already exist, it will be created.
YAML::Store
objects are always reentrant. But if thread_safe is set to true, then it will become thread-safe at the cost of a minor performance hit.
Options passed in through yaml_opts
will be used when converting the store to YAML via Hash#to_yaml()
.
possible options elements:
hash form: :invalid => nil # raise error on invalid byte sequence (default) :invalid => :replace # replace invalid byte sequence :undef => nil # raise error on undefined conversion (default) :undef => :replace # replace undefined conversion :replace => string # replacement string ("?" or "\uFFFD" if not specified) :newline => :universal # decorator for converting CRLF and CR to LF :newline => :crlf # decorator for converting LF to CRLF :newline => :cr # decorator for converting LF to CR :universal_newline => true # decorator for converting CRLF and CR to LF :crlf_newline => true # decorator for converting LF to CRLF :cr_newline => true # decorator for converting LF to CR :xml => :text # escape as XML CharData. :xml => :attr # escape as XML AttValue integer form: Encoding::Converter::INVALID_REPLACE Encoding::Converter::UNDEF_REPLACE Encoding::Converter::UNDEF_HEX_CHARREF Encoding::Converter::UNIVERSAL_NEWLINE_DECORATOR Encoding::Converter::CRLF_NEWLINE_DECORATOR Encoding::Converter::CR_NEWLINE_DECORATOR Encoding::Converter::XML_TEXT_DECORATOR Encoding::Converter::XML_ATTR_CONTENT_DECORATOR Encoding::Converter::XML_ATTR_QUOTE_DECORATOR
Encoding::Converter.new
creates an instance of Encoding::Converter
.
Source_encoding and destination_encoding
should be a string or Encoding
object.
opt should be nil, a hash or an integer.
convpath should be an array. convpath may contain
two-element arrays which contain encodings or encoding names, or
strings representing decorator names.
Encoding::Converter.new
optionally takes an option. The option should be a hash or an integer. The option hash can contain :invalid => nil, etc. The option integer should be logical-or of constants such as Encoding::Converter::INVALID_REPLACE
, etc.
Raise error on invalid byte sequence. This is a default behavior.
Replace invalid byte sequence by replacement string.
Raise an error if a character in source_encoding
is not defined in destination_encoding. This is a default behavior.
Replace undefined character in destination_encoding
with replacement string.
Specify the replacement string. If not specified, “uFFFD” is used for Unicode encodings and “?” for others.
Convert CRLF and CR to LF.
Convert LF to CRLF.
Convert LF to CR.
Escape as XML
CharData. This form can be used as an HTML 4.0 PCDATA.
‘&’ -> ‘&’
‘<’ -> ‘<’
‘>’ -> ‘>’
undefined characters in destination_encoding
-> hexadecimal CharRef such as &#xHH;
Escape as XML
AttValue. The converted result is quoted as “…”. This form can be used as an HTML 4.0 attribute value.
‘&’ -> ‘&’
‘<’ -> ‘<’
‘>’ -> ‘>’
‘“’ -> ‘"’
undefined characters in destination_encoding
-> hexadecimal CharRef such as &#xHH;
Examples:
# UTF-16BE to UTF-8 ec = Encoding::Converter.new("UTF-16BE", "UTF-8") # Usually, decorators such as newline conversion are inserted last. ec = Encoding::Converter.new("UTF-16BE", "UTF-8", :universal_newline => true) p ec.convpath #=> [[#<Encoding:UTF-16BE>, #<Encoding:UTF-8>], # "universal_newline"] # But, if the last encoding is ASCII incompatible, # decorators are inserted before the last conversion. ec = Encoding::Converter.new("UTF-8", "UTF-16BE", :crlf_newline => true) p ec.convpath #=> ["crlf_newline", # [#<Encoding:UTF-8>, #<Encoding:UTF-16BE>]] # Conversion path can be specified directly. ec = Encoding::Converter.new(["universal_newline", ["EUC-JP", "UTF-8"], ["UTF-8", "UTF-16BE"]]) p ec.convpath #=> ["universal_newline", # [#<Encoding:EUC-JP>, #<Encoding:UTF-8>], # [#<Encoding:UTF-8>, #<Encoding:UTF-16BE>]]
Returns a new, initialized copy of the digest object. Equivalent to digest_obj.clone().reset().
Creates an instance of OpenSSL’s buffering IO
module.
newton.rb
Solves the nonlinear algebraic equation system f = 0 by Newton’s method. This program is not dependent on BigDecimal
.
To call:
n = nlsolve(f,x) where n is the number of iterations required, x is the initial value vector f is an Object which is used to compute the values of the equations to be solved.
It must provide the following methods:
returns the values of all functions at x
returns 0.0
returns 1.0
returns 2.0
returns 10.0
returns the convergence criterion (epsilon value) used to determine whether two values are considered equal. If |a-b| < epsilon, the two values are considered equal.
On exit, x is the solution vector.
URI::Parser.new([opts])
The constructor accepts a hash as options for parser. Keys of options are pattern names of URI
components and values of options are pattern strings. The constructor generates set of regexps for parsing URIs.
You can use the following keys:
* :ESCAPED (URI::PATTERN::ESCAPED in default) * :UNRESERVED (URI::PATTERN::UNRESERVED in default) * :DOMLABEL (URI::PATTERN::DOMLABEL in default) * :TOPLABEL (URI::PATTERN::TOPLABEL in default) * :HOSTNAME (URI::PATTERN::HOSTNAME in default)
p = URI::Parser.new(:ESCAPED => "(?:%[a-fA-F0-9]{2}|%u[a-fA-F0-9]{4})") u = p.parse("http://example.jp/%uABCD") #=> #<URI::HTTP http://example.jp/%uABCD> URI.parse(u.to_s) #=> raises URI::InvalidURIError s = "http://example.com/ABCD" u1 = p.parse(s) #=> #<URI::HTTP http://example.com/ABCD> u2 = URI.parse(s) #=> #<URI::HTTP http://example.com/ABCD> u1 == u2 #=> true u1.eql?(u2) #=> false