Duplicates a StringScanner
object.
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
Defines the callback event. If argument is omitted, this method defines the callback of all events. If you want to modify reference argument in callback, return hash in callback. If you want to return value to OLE server as result of callback use ‘return’ or :return.
ie = WIN32OLE.new('InternetExplorer.Application') ev = WIN32OLE_EVENT.new(ie) ev.on_event("NavigateComplete") {|url| puts url} ev.on_event() {|ev, *args| puts "#{ev} fired"} ev.on_event("BeforeNavigate2") {|*args| ... # set true to BeforeNavigate reference argument `Cancel'. # Cancel is 7-th argument of BeforeNavigate, # so you can use 6 as key of hash instead of 'Cancel'. # The argument is counted from 0. # The hash key of 0 means first argument.) {:Cancel => true} # or {'Cancel' => true} or {6 => true} } ev.on_event(...) {|*args| {:return => 1, :xxx => yyy} }
Evaluates a string containing Ruby source code, or the given block, within the context of the receiver (obj). In order to set the context, the variable self
is set to obj while the code is executing, giving the code access to obj’s instance variables and private methods.
When instance_eval
is given a block, obj is also passed in as the block’s only argument.
When instance_eval
is given a String
, the optional second and third parameters supply a filename and starting line number that are used when reporting compilation errors.
class KlassWithSecret def initialize @secret = 99 end private def the_secret "Ssssh! The secret is #{@secret}." end end k = KlassWithSecret.new k.instance_eval { @secret } #=> 99 k.instance_eval { the_secret } #=> "Ssssh! The secret is 99." k.instance_eval {|obj| obj == self } #=> true
Executes the given block within the context of the receiver (obj). In order to set the context, the variable self
is set to obj while the code is executing, giving the code access to obj’s instance variables. Arguments are passed as block parameters.
class KlassWithSecret def initialize @secret = 99 end end k = KlassWithSecret.new k.instance_exec(5) {|x| @secret+x } #=> 104
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
Returns the current list of converters in effect for headers. See CSV::new
for details. Built-in converters will be returned by name, while others will be returned as is.
Identical to CSV#convert()
, but for header rows.
Note that this method must be called before header rows are read to have any effect.
Loads any converters requested during construction.
If field_name
is set :converters
(the default) field converters are set. When field_name
is :header_converters
header converters are added instead.
The :unconverted_fields
option is also activated for :converters
calls, if requested.
The actual work method for adding converters, used by both CSV.convert()
and CSV.header_convert()
.
This method requires the var_name
of the instance variable to place the converters in, the const
Hash
to lookup named converters in, and the normal parameters of the CSV.convert()
and CSV.header_convert()
methods.
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.
Set
date-time format.
datetime_format
A string suitable for passing to strftime
.
Returns the date format being used. See datetime_format=
Creates a single-row matrix where the values of that row are as given in row
.
Matrix.row_vector([4,5,6]) => 4 5 6
Creates a single-column matrix where the values of that column are as given in column
.
Matrix.column_vector([4,5,6]) => 4 5 6
Returns the number of rows.
Returns an array of the row vectors of the matrix. See Vector
.
Returns an array of the column vectors of the matrix. See Vector
.
Add option switch like with on
, but at head of summary.
Add option switch like with on
, but at tail of summary.
Add option switch like with on
, but at head of summary.