WIN32OLE::Variant
objects represents OLE variant.
Win32OLE converts Ruby object into OLE variant automatically when invoking OLE methods. If OLE method requires the argument which is different from the variant by automatic conversion of Win32OLE, you can convert the specified variant type by using WIN32OLE::Variant
class.
param = WIN32OLE::Variant.new(10, WIN32OLE::VARIANT::VT_R4) oleobj.method(param)
WIN32OLE::Variant
does not support VT_RECORD variant. Use WIN32OLE::Record
class instead of WIN32OLE::Variant
if the VT_RECORD variant is needed.
Zlib::GzipWriter
is a class for writing gzipped files. GzipWriter
should be used with an instance of IO
, or IO-like, object.
Following two example generate the same result.
Zlib::GzipWriter.open('hoge.gz') do |gz| gz.write 'jugemu jugemu gokou no surikire...' end File.open('hoge.gz', 'w') do |f| gz = Zlib::GzipWriter.new(f) gz.write 'jugemu jugemu gokou no surikire...' gz.close end
To make like gzip(1) does, run following:
orig = 'hoge.txt' Zlib::GzipWriter.open('hoge.gz') do |gz| gz.mtime = File.mtime(orig) gz.orig_name = orig gz.write IO.binread(orig) end
NOTE: Due to the limitation of Ruby’s finalizer, you must explicitly close GzipWriter
objects by Zlib::GzipWriter#close
etc. Otherwise, GzipWriter
will be not able to write the gzip footer and will generate a broken gzip file.
exception to wait for reading by EAGAIN. see IO.select
.
exception to wait for reading by EWOULDBLOCK. see IO.select
.
exception to wait for reading by EINPROGRESS. see IO.select
.
This class is the base class for Net::HTTP response classes.
Method Net::HTTP.get_response
returns an instance of one of the subclasses of Net::HTTPResponse:
Net::HTTP.get_response(uri) # => #<Net::HTTPOK 200 OK readbody=true> Net::HTTP.get_response(hostname, '/nosuch') # => #<Net::HTTPNotFound 404 Not Found readbody=true>
As does method Net::HTTP#request
:
req = Net::HTTP::Get.new(uri) Net::HTTP.start(hostname) do |http| http.request(req) end # => #<Net::HTTPOK 200 OK readbody=true>
Class Net::HTTPResponse includes module Net::HTTPHeader
, which provides access to response header values via (among others):
Hash-like method []
.
Specific reader methods, such as content_type
.
Examples:
res = Net::HTTP.get_response(uri) # => #<Net::HTTPOK 200 OK readbody=true> res['Content-Type'] # => "text/html; charset=UTF-8" res.content_type # => "text/html"
Class Net::HTTPResponse has a subclass for each HTTP status code. You can look up the response class for a given code:
Net::HTTPResponse::CODE_TO_OBJ['200'] # => Net::HTTPOK Net::HTTPResponse::CODE_TO_OBJ['400'] # => Net::HTTPBadRequest Net::HTTPResponse::CODE_TO_OBJ['404'] # => Net::HTTPNotFound
And you can retrieve the status code for a response object:
Net::HTTP.get_response(uri).code # => "200" Net::HTTP.get_response(hostname, '/nosuch').code # => "404"
The response subclasses (indentation shows class hierarchy):
Net::HTTPUnknownResponse
(for unhandled HTTP extensions).
Net::HTTPContinue
(100)
Net::HTTPSwitchProtocol
(101)
Net::HTTPProcessing
(102)
Net::HTTPEarlyHints
(103)
Net::HTTPOK
(200)
Net::HTTPCreated
(201)
Net::HTTPAccepted
(202)
Net::HTTPNoContent
(204)
Net::HTTPResetContent
(205)
Net::HTTPPartialContent
(206)
Net::HTTPMultiStatus
(207)
Net::HTTPAlreadyReported
(208)
Net::HTTPIMUsed
(226)
Net::HTTPMultipleChoices
(300)
Net::HTTPFound
(302)
Net::HTTPSeeOther
(303)
Net::HTTPNotModified
(304)
Net::HTTPUseProxy
(305)
Net::HTTPBadRequest
(400)
Net::HTTPUnauthorized
(401)
Net::HTTPPaymentRequired
(402)
Net::HTTPForbidden
(403)
Net::HTTPNotFound
(404)
Net::HTTPNotAcceptable
(406)
Net::HTTPRequestTimeOut
(408)
Net::HTTPConflict
(409)
Net::HTTPGone
(410)
Net::HTTPLengthRequired
(411)
Net::HTTPLocked
(423)
Net::HTTPUpgradeRequired
(426)
Net::HTTPTooManyRequests
(429)
Net::HTTPNotImplemented
(501)
Net::HTTPBadGateway
(502)
Net::HTTPGatewayTimeOut
(504)
Net::HTTPLoopDetected
(508)
Net::HTTPNotExtended
(510)
There is also the Net::HTTPBadResponse exception which is raised when there is a protocol error.
Response class for Switching Protocol
responses (status code 101).
The <tt>Switching Protocol<tt> response indicates that the server has received a request to switch protocols, and has agreed to do so.
References:
Response class for Early Hints
responses (status code 103).
The Early Hints
indicates that the server has received and is processing the request, and contains certain headers; the final response is not available yet.
References:
Response class for Accepted
responses (status code 202).
The Accepted
response indicates that the server has received and is processing a request, but the processing has not yet been completed.
References:
Response class for No Content
responses (status code 204).
The No Content
response indicates that the server successfully processed the request, and is not returning any content.
References:
Response class for Reset Content
responses (status code 205).
The Reset Content
response indicates that the server successfully processed the request, asks that the client reset its document view, and is not returning any content.
References:
Response class for Found
responses (status code 302).
The Found
response indicates that the client should look at (browse to) another URL.
References:
Response class for Temporary Redirect
responses (status code 307).
The request should be repeated with another URI
; however, future requests should still use the original URI
.
References:
Response class for Payment Required
responses (status code 402).
Reserved for future use.
References:
Response class for Conflict
responses (status code 409).
The request could not be processed because of conflict in the current state of the resource.
References:
Response class for Gone
responses (status code 410).
The resource requested was previously in use but is no longer available and will not be available again.
References:
Response class for Unsupported Media Type
responses (status code 415).
The request entity has a media type which the server or resource does not support.
References:
Response class for Request Header Fields Too Large
responses (status code 431).
An individual header field is too large, or all the header fields collectively, are too large.
References:
Response class for Unavailable For Legal Reasons
responses (status code 451).
A server operator has received a legal demand to deny access to a resource or to a set of resources that includes the requested resource.
References:
The writer adapter class