Class: WIN32OLE_METHOD

Inherits:
Object
  • Object
show all
Defined in:
win32ole_method.c,
win32ole_method.c

Overview

WIN32OLE_METHOD objects represent OLE method information.

Instance Method Summary collapse

Constructor Details

#new(ole_type, method) ⇒ WIN32OLE_METHOD object

Returns a new WIN32OLE_METHOD object which represents the information about OLE method. The first argument ole_type specifies WIN32OLE_TYPE object. The second argument method specifies OLE method name defined OLE class which represents WIN32OLE_TYPE object.

tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook')
method = WIN32OLE_METHOD.new(tobj, 'SaveAs')


265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
# File 'win32ole_method.c', line 265

static VALUE
folemethod_initialize(VALUE self, VALUE oletype, VALUE method)
{
    VALUE obj = Qnil;
    ITypeInfo *pTypeInfo;
    if (rb_obj_is_kind_of(oletype, cWIN32OLE_TYPE)) {
        SafeStringValue(method);
        pTypeInfo = itypeinfo(oletype);
        obj = olemethod_from_typeinfo(self, pTypeInfo, method);
        if (obj == Qnil) {
            rb_raise(eWIN32OLERuntimeError, "not found %s",
                     StringValuePtr(method));
        }
    }
    else {
        rb_raise(rb_eTypeError, "1st argument should be WIN32OLE_TYPE object");
    }
    return obj;
}

Instance Method Details

#dispidObject

Returns dispatch ID.

tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks')
method = WIN32OLE_METHOD.new(tobj, 'Add')
puts method.dispid # => 181


758
759
760
761
762
763
764
# File 'win32ole_method.c', line 758

static VALUE
folemethod_dispid(VALUE self)
{
    struct olemethoddata *pmethod;
    TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
    return ole_method_dispid(pmethod->pTypeInfo, pmethod->index);
}

#event?Boolean

Returns true 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? # => true

Returns:

  • (Boolean)


586
587
588
589
590
591
592
593
594
595
596
# File 'win32ole_method.c', line 586

static VALUE
folemethod_event(VALUE self)
{
    struct olemethoddata *pmethod;
    TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
    if (!pmethod->pOwnerTypeInfo)
        return Qfalse;
    return ole_method_event(pmethod->pOwnerTypeInfo,
                            pmethod->index,
                            rb_ivar_get(self, rb_intern("name")));
}

#event_interfaceObject

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


607
608
609
610
611
612
613
614
615
616
617
618
619
620
# File 'win32ole_method.c', line 607

static VALUE
folemethod_event_interface(VALUE self)
{
    BSTR name;
    struct olemethoddata *pmethod;
    HRESULT hr;
    TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
    if(folemethod_event(self) == Qtrue) {
        hr = ole_docinfo_from_type(pmethod->pTypeInfo, &name, NULL, NULL, NULL);
        if(SUCCEEDED(hr))
            return WC2VSTR(name);
    }
    return Qnil;
}

#helpcontextObject

Returns help context.

tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks')
method = WIN32OLE_METHOD.new(tobj, 'Add')
puts method.helpcontext # => 65717


727
728
729
730
731
732
733
# File 'win32ole_method.c', line 727

static VALUE
folemethod_helpcontext(VALUE self)
{
    struct olemethoddata *pmethod;
    TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
    return ole_method_helpcontext(pmethod->pTypeInfo, pmethod->index);
}

#helpfileObject

Returns help file. If help file is not found, then the method returns nil.

tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks')
method = WIN32OLE_METHOD.new(tobj, 'Add')
puts method.helpfile # => C:\...\VBAXL9.CHM


697
698
699
700
701
702
703
704
# File 'win32ole_method.c', line 697

static VALUE
folemethod_helpfile(VALUE self)
{
    struct olemethoddata *pmethod;
    TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);

    return ole_method_helpfile(pmethod->pTypeInfo, pmethod->index);
}

#helpstringObject

Returns help string of OLE method. If the help string is not found, then the method returns nil.

tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', 'IWebBrowser')
method = WIN32OLE_METHOD.new(tobj, 'Navigate')
puts method.helpstring # => Navigates to a URL or file.


667
668
669
670
671
672
673
# File 'win32ole_method.c', line 667

static VALUE
folemethod_helpstring(VALUE self)
{
    struct olemethoddata *pmethod;
    TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
    return ole_method_helpstring(pmethod->pTypeInfo, pmethod->index);
}

#inspectString

Returns the method name with class name.

Returns:

  • (String)


920
921
922
923
924
# File 'win32ole_method.c', line 920

static VALUE
folemethod_inspect(VALUE self)
{
    return default_inspect(self, "WIN32OLE_METHOD");
}

#invkindObject

Returns the method invoke kind.

tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks')
method = WIN32OLE_METHOD.new(tobj, 'Add')
puts method.invkind # => 1


448
449
450
451
452
453
454
# File 'win32ole_method.c', line 448

static VALUE
folemethod_invkind(VALUE self)
{
    struct olemethoddata *pmethod;
    TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
    return ole_method_invkind(pmethod->pTypeInfo, pmethod->index);
}

#invoke_kindObject

Returns the method kind string. The string is “UNKNOWN” or “PROPERTY” or “PROPERTY” or “PROPERTYGET” or “PROPERTYPUT” or “PROPERTYPPUTREF” or “FUNC”.

tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks')
method = WIN32OLE_METHOD.new(tobj, 'Add')
puts method.invoke_kind # => "FUNC"


467
468
469
470
471
472
473
# File 'win32ole_method.c', line 467

static VALUE
folemethod_invoke_kind(VALUE self)
{
    struct olemethoddata *pmethod;
    TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
    return ole_method_invoke_kind(pmethod->pTypeInfo, pmethod->index);
}

#nameObject Also known as: to_s

Returns the name of the method.

tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook')
method = WIN32OLE_METHOD.new(tobj, 'SaveAs')
puts method.name # => SaveAs


296
297
298
299
300
# File 'win32ole_method.c', line 296

static VALUE
folemethod_name(VALUE self)
{
    return rb_ivar_get(self, rb_intern("name"));
}

#offset_vtblObject

Returns the offset ov VTBL.

tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks')
method = WIN32OLE_METHOD.new(tobj, 'Add')
puts method.offset_vtbl # => 40


789
790
791
792
793
794
795
# File 'win32ole_method.c', line 789

static VALUE
folemethod_offset_vtbl(VALUE self)
{
    struct olemethoddata *pmethod;
    TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
    return ole_method_offset_vtbl(pmethod->pTypeInfo, pmethod->index);
}

#paramsObject

returns array of WIN32OLE_PARAM object corresponding with method parameters.

tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook')
method = WIN32OLE_METHOD.new(tobj, 'SaveAs')
p method.params # => [Filename, FileFormat, Password, WriteResPassword,
                      ReadOnlyRecommended, CreateBackup, AccessMode,
                      ConflictResolution, AddToMru, TextCodepage,
                      TextVisualLayout]


905
906
907
908
909
910
911
# File 'win32ole_method.c', line 905

static VALUE
folemethod_params(VALUE self)
{
    struct olemethoddata *pmethod;
    TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
    return ole_method_params(pmethod->pTypeInfo, pmethod->index);
}

#return_typeObject

Returns string of return value type of method.

tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks')
method = WIN32OLE_METHOD.new(tobj, 'Add')
puts method.return_type # => Workbook


328
329
330
331
332
333
334
# File 'win32ole_method.c', line 328

static VALUE
folemethod_return_type(VALUE self)
{
    struct olemethoddata *pmethod;
    TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
    return ole_method_return_type(pmethod->pTypeInfo, pmethod->index);
}

#return_type_detailObject

Returns detail information of return value type of method. The information is array.

tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks')
method = WIN32OLE_METHOD.new(tobj, 'Add')
p method.return_type_detail # => ["PTR", "USERDEFINED", "Workbook"]


396
397
398
399
400
401
402
# File 'win32ole_method.c', line 396

static VALUE
folemethod_return_type_detail(VALUE self)
{
    struct olemethoddata *pmethod;
    TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
    return ole_method_return_type_detail(pmethod->pTypeInfo, pmethod->index);
}

#return_vtypeObject

Returns number of return value type of method.

tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks')
method = WIN32OLE_METHOD.new(tobj, 'Add')
puts method.return_vtype # => 26


362
363
364
365
366
367
368
# File 'win32ole_method.c', line 362

static VALUE
folemethod_return_vtype(VALUE self)
{
    struct olemethoddata *pmethod;
    TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
    return ole_method_return_vtype(pmethod->pTypeInfo, pmethod->index);
}

#size_opt_paramsObject

Returns the size of optional parameters.

tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook')
method = WIN32OLE_METHOD.new(tobj, 'SaveAs')
puts method.size_opt_params # => 4


852
853
854
855
856
857
858
# File 'win32ole_method.c', line 852

static VALUE
folemethod_size_opt_params(VALUE self)
{
    struct olemethoddata *pmethod;
    TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
    return ole_method_size_opt_params(pmethod->pTypeInfo, pmethod->index);
}

#size_paramsObject

Returns the size of arguments of the method.

tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook')
method = WIN32OLE_METHOD.new(tobj, 'SaveAs')
puts method.size_params # => 11


821
822
823
824
825
826
827
# File 'win32ole_method.c', line 821

static VALUE
folemethod_size_params(VALUE self)
{
    struct olemethoddata *pmethod;
    TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
    return ole_method_size_params(pmethod->pTypeInfo, pmethod->index);
}

#visible?Boolean

Returns true if the method is public.

tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks')
method = WIN32OLE_METHOD.new(tobj, 'Add')
puts method.visible? # => true

Returns:

  • (Boolean)


504
505
506
507
508
509
510
# File 'win32ole_method.c', line 504

static VALUE
folemethod_visible(VALUE self)
{
    struct olemethoddata *pmethod;
    TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
    return ole_method_visible(pmethod->pTypeInfo, pmethod->index);
}