Defines the constants of OLE Automation server as mod’s constants. The first argument is WIN32OLE
object or type library name. If 2nd argument is omitted, the default is WIN32OLE
. The first letter of Ruby’s constant variable name is upper case, so constant variable name of WIN32OLE
object is capitalized. For example, the ‘xlTop’ constant of Excel is changed to ‘XlTop’ in WIN32OLE
. If the first letter of constant variable is not [A-Z], then the constant is defined as CONSTANTS hash element.
module EXCEL_CONST end excel = WIN32OLE.new('Excel.Application') WIN32OLE.const_load(excel, EXCEL_CONST) puts EXCEL_CONST::XlTop # => -4160 puts EXCEL_CONST::CONSTANTS['_xlDialogChartSourceData'] # => 541 WIN32OLE.const_load(excel) puts WIN32OLE::XlTop # => -4160 module MSO end WIN32OLE.const_load('Microsoft Office 9.0 Object Library', MSO) puts MSO::MsoLineSingle # => 1
Returns event interface name if the method is event.
tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook') method = WIN32OLE_METHOD.new(tobj, 'SheetActivate') puts method.event_interface # => WorkbookEvents
Returns major version.
tobj = WIN32OLE_TYPE.new('Microsoft Word 10.0 Object Library', 'Documents') puts tobj.major_version # => 8
Returns minor version.
tobj = WIN32OLE_TYPE.new('Microsoft Word 10.0 Object Library', 'Documents') puts tobj.minor_version # => 2
Returns the type library major version.
tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library') puts tlib.major_version # -> 1
Returns the type library minor version.
tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library') puts tlib.minor_version # -> 3
Try to convert obj into a hash, using to_hash
method. Returns converted hash or nil if obj cannot be converted for any reason.
Hash.try_convert({1=>2}) # => {1=>2} Hash.try_convert("1=>2") # => nil
Reads at most maxlen bytes from the ARGF
stream in non-blocking mode.
Returns the external encoding for files read from ARGF
as an Encoding
object. The external encoding is the encoding of the text as stored in a file. Contrast with ARGF.internal_encoding
, which is the encoding used to represent this text within Ruby.
To set the external encoding use ARGF.set_encoding
.
For example:
ARGF.external_encoding #=> #<Encoding:UTF-8>
Returns the internal encoding for strings read from ARGF
as an Encoding
object.
If ARGF.set_encoding
has been called with two encoding names, the second is returned. Otherwise, if Encoding.default_external
has been set, that value is returned. Failing that, if a default external encoding was specified on the command-line, that value is used. If the encoding is unknown, nil
is returned.
Create an HTTP header block as a string.
Includes the empty line that ends the header block.
content_type_string
If this form is used, this string is the Content-Type
headers_hash
A Hash
of header values. The following header keys are recognized:
The Content-Type header. Defaults to “text/html”
The charset of the body, appended to the Content-Type header.
A boolean value. If true, prepend protocol string and status code, and date; and sets default values for “server” and “connection” if not explicitly set.
The HTTP status code as a String, returned as the Status header. The values are:
200 OK
206 Partial Content
300 Multiple Choices
301 Moved Permanently
302 Found
304 Not Modified
400 Bad Request
401 Authorization Required
403 Forbidden
404 Not Found
405 Method
Not Allowed
406 Not Acceptable
411 Length Required
412 Precondition Failed
500 Internal Server Error
501 Method
Not Implemented
502 Bad Gateway
506 Variant Also Negotiates
The server software, returned as the Server header.
The connection type, returned as the Connection header (for instance, “close”.
The length of the content that will be sent, returned as the Content-Length header.
The language of the content, returned as the Content-Language header.
The time on which the current content expires, as a Time
object, returned as the Expires header.
A cookie or cookies, returned as one or more Set-Cookie headers. The value can be the literal string of the cookie; a CGI::Cookie
object; an Array of literal cookie strings or Cookie
objects; or a hash all of whose values are literal cookie strings or Cookie
objects.
These cookies are in addition to the cookies held in the @output_cookies field.
Other headers can also be set; they are appended as key: value.
Examples:
http_header # Content-Type: text/html http_header("text/plain") # Content-Type: text/plain http_header("nph" => true, "status" => "OK", # == "200 OK" # "status" => "200 GOOD", "server" => ENV['SERVER_SOFTWARE'], "connection" => "close", "type" => "text/html", "charset" => "iso-2022-jp", # Content-Type: text/html; charset=iso-2022-jp "length" => 103, "language" => "ja", "expires" => Time.now + 30, "cookie" => [cookie1, cookie2], "my_header1" => "my_value", "my_header2" => "my_value")
This method does not perform charset conversion.
Returns true
if unconverted_fields() to parsed results. See CSV::new
for details.
Returns true
if headers will be returned as a row of results. See CSV::new
for details.
Returns true
if headers are written in output. See CSV::new
for details.
Returns true
if illegal input is handled. See CSV::new
for details.
Returns true
if the next row read will be a header row.
Pre-compiles parsers and stores them by name for access during reads.
Processes fields
with @converters
, or @header_converters
if headers
is passed as true
, returning the converted field set. Any converter that changes the field into something other than a String halts the pipeline of conversion for that field. This is primarily an efficiency shortcut.
This method is used to turn a finished row
into a CSV::Row
. Header rows are also dealt with here, either by returning a CSV::Row
with identical headers and fields (save that the fields do not go through the converters) or by reading past them to return a field row. Headers are also saved in @headers
for use in future rows.
When nil
, row
is assumed to be a header row not based on an actual row of the stream.
Used to filter unwanted trace output
Example which only outputs lines of code executed within the Kernel class:
Tracer.add_filter do |event, file, line, id, binding, klass, *rest| "Kernel" == klass.to_s end
Reinitializes delegation from a serialized object.
Allow connections from Socket
soc
?
Allow connections from addrinfo addr
? It must be formatted like Socket#peeraddr:
["AF_INET", 10, "lc630", "192.0.2.1"]
Creates a new compiler for ERB
. See ERB::Compiler.new for details