Class: WIN32OLE_METHOD

Inherits:
Object
  • Object
show all
Defined in:
win32ole.c,
win32ole.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')


6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
# File 'win32ole.c', line 6594

static VALUE
folemethod_initialize(VALUE self, VALUE oletype, VALUE method)
{
    struct oletypedata *ptype;
    VALUE obj = Qnil;
    if (rb_obj_is_kind_of(oletype, cWIN32OLE_TYPE)) {
        SafeStringValue(method);
        Data_Get_Struct(oletype, struct oletypedata, ptype);
        obj = olemethod_from_typeinfo(self, ptype->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


7087
7088
7089
7090
7091
7092
7093
# File 'win32ole.c', line 7087

static VALUE
folemethod_dispid(VALUE self)
{
    struct olemethoddata *pmethod;
    Data_Get_Struct(self, struct olemethoddata, 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)


6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
# File 'win32ole.c', line 6915

static VALUE
folemethod_event(VALUE self)
{
    struct olemethoddata *pmethod;
    Data_Get_Struct(self, struct olemethoddata, 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


6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
# File 'win32ole.c', line 6936

static VALUE
folemethod_event_interface(VALUE self)
{
    BSTR name;
    struct olemethoddata *pmethod;
    HRESULT hr;
    Data_Get_Struct(self, struct olemethoddata, 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


7056
7057
7058
7059
7060
7061
7062
# File 'win32ole.c', line 7056

static VALUE
folemethod_helpcontext(VALUE self)
{
    struct olemethoddata *pmethod;
    Data_Get_Struct(self, struct olemethoddata, 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


7026
7027
7028
7029
7030
7031
7032
7033
# File 'win32ole.c', line 7026

static VALUE
folemethod_helpfile(VALUE self)
{
    struct olemethoddata *pmethod;
    Data_Get_Struct(self, struct olemethoddata, 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.


6996
6997
6998
6999
7000
7001
7002
# File 'win32ole.c', line 6996

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

#inspectString

Returns the method name with class name.

Returns:

  • (String)


7257
7258
7259
7260
7261
# File 'win32ole.c', line 7257

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


6777
6778
6779
6780
6781
6782
6783
# File 'win32ole.c', line 6777

static VALUE
folemethod_invkind(VALUE self)
{
    struct olemethoddata *pmethod;
    Data_Get_Struct(self, struct olemethoddata, 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"


6796
6797
6798
6799
6800
6801
6802
# File 'win32ole.c', line 6796

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

#nameObject Also known as: to_s

call-seq

WIN32OLE_METHOD#name

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


6625
6626
6627
6628
6629
# File 'win32ole.c', line 6625

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


7118
7119
7120
7121
7122
7123
7124
# File 'win32ole.c', line 7118

static VALUE
folemethod_offset_vtbl(VALUE self)
{
    struct olemethoddata *pmethod;
    Data_Get_Struct(self, struct olemethoddata, 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]


7242
7243
7244
7245
7246
7247
7248
# File 'win32ole.c', line 7242

static VALUE
folemethod_params(VALUE self)
{
    struct olemethoddata *pmethod;
    Data_Get_Struct(self, struct olemethoddata, 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


6657
6658
6659
6660
6661
6662
6663
# File 'win32ole.c', line 6657

static VALUE
folemethod_return_type(VALUE self)
{
    struct olemethoddata *pmethod;
    Data_Get_Struct(self, struct olemethoddata, 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"]


6725
6726
6727
6728
6729
6730
6731
# File 'win32ole.c', line 6725

static VALUE
folemethod_return_type_detail(VALUE self)
{
    struct olemethoddata *pmethod;
    Data_Get_Struct(self, struct olemethoddata, 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


6691
6692
6693
6694
6695
6696
6697
# File 'win32ole.c', line 6691

static VALUE
folemethod_return_vtype(VALUE self)
{
    struct olemethoddata *pmethod;
    Data_Get_Struct(self, struct olemethoddata, 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


7181
7182
7183
7184
7185
7186
7187
# File 'win32ole.c', line 7181

static VALUE
folemethod_size_opt_params(VALUE self)
{
    struct olemethoddata *pmethod;
    Data_Get_Struct(self, struct olemethoddata, 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


7150
7151
7152
7153
7154
7155
7156
# File 'win32ole.c', line 7150

static VALUE
folemethod_size_params(VALUE self)
{
    struct olemethoddata *pmethod;
    Data_Get_Struct(self, struct olemethoddata, 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)


6833
6834
6835
6836
6837
6838
6839
# File 'win32ole.c', line 6833

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