Class: WIN32OLE::Param
Relationships & Source Files | |
Inherits: | Object |
Defined in: | ext/win32ole/win32ole_param.c, ext/win32ole/win32ole_param.c |
Overview
Param
objects represent param information of the OLE method.
Class Method Summary
-
.new(method, n) ⇒ Param
constructor
Returns
Param
object which represents OLE parameter information.
Instance Attribute Summary
-
#input? ⇒ Boolean
readonly
Returns true if the parameter is input.
-
#optional? ⇒ Boolean
readonly
Returns true if argument is optional.
-
#output? ⇒ Boolean
readonly
Returns true if argument is output.
-
#retval? ⇒ Boolean
readonly
Returns true if argument is return value.
Instance Method Summary
-
#default
Returns default value.
-
#inspect ⇒ String
Returns the parameter name with class name.
-
#name
Alias for #to_s.
-
#ole_type_detail
Returns detail information of type of argument.
-
#to_s
(also: #name)
Returns name.
Constructor Details
.new(method, n) ⇒ Param
Returns Param
object which represents OLE parameter information. 1st argument should be Method
object. 2nd argument ānā is n-th parameter of the method specified by 1st argument.
tobj = WIN32OLE::Type.new('Microsoft Scripting Runtime', 'IFileSystem')
method = WIN32OLE::Method.new(tobj, 'CreateTextFile')
param = WIN32OLE::Param.new(method, 2) # => #<WIN32OLE::Param:Overwrite=true>
# File 'ext/win32ole/win32ole_param.c', line 145
static VALUE foleparam_initialize(VALUE self, VALUE olemethod, VALUE n) { int idx; if (!rb_obj_is_kind_of(olemethod, cWIN32OLE_METHOD)) { rb_raise(rb_eTypeError, "1st parameter must be WIN32OLE::Method object"); } idx = RB_FIX2INT(n); return oleparam_ole_param(self, olemethod, idx); }
Instance Attribute Details
#input? ⇒ Boolean
(readonly)
# File 'ext/win32ole/win32ole_param.c', line 265
static VALUE foleparam_input(VALUE self) { struct oleparamdata *pparam; TypedData_Get_Struct(self, struct oleparamdata, &oleparam_datatype, pparam); return ole_param_flag_mask(pparam->pTypeInfo, pparam->method_index, pparam->index, PARAMFLAG_FIN); }
#optional? ⇒ Boolean
(readonly)
# File 'ext/win32ole/win32ole_param.c', line 312
static VALUE foleparam_optional(VALUE self) { struct oleparamdata *pparam; TypedData_Get_Struct(self, struct oleparamdata, &oleparam_datatype, pparam); return ole_param_flag_mask(pparam->pTypeInfo, pparam->method_index, pparam->index, PARAMFLAG_FOPT); }
#output? ⇒ Boolean
(readonly)
Returns true if argument is output.
tobj = WIN32OLE::Type.new('Microsoft Internet Controls', 'DWebBrowserEvents')
method = WIN32OLE::Method.new(tobj, 'NewWindow')
method.params.each do |param|
puts "#{param.name} #{param.output?}"
end
The result of above script is following:
URL false
Flags false
TargetFrameName false
PostData false
Headers false
Processed true
# File 'ext/win32ole/win32ole_param.c', line 293
static VALUE foleparam_output(VALUE self) { struct oleparamdata *pparam; TypedData_Get_Struct(self, struct oleparamdata, &oleparam_datatype, pparam); return ole_param_flag_mask(pparam->pTypeInfo, pparam->method_index, pparam->index, PARAMFLAG_FOUT); }
#retval? ⇒ Boolean
(readonly)
# File 'ext/win32ole/win32ole_param.c', line 332
static VALUE foleparam_retval(VALUE self) { struct oleparamdata *pparam; TypedData_Get_Struct(self, struct oleparamdata, &oleparam_datatype, pparam); return ole_param_flag_mask(pparam->pTypeInfo, pparam->method_index, pparam->index, PARAMFLAG_FRETVAL); }
Instance Method Details
#default
Returns default value. If the default value does not exist, this method returns nil.
tobj = WIN32OLE::Type.new('Microsoft Excel 9.0 Object Library', 'Workbook')
method = WIN32OLE::Method.new(tobj, 'SaveAs')
method.params.each do |param|
if param.default
puts "#{param.name} (= #{param.default})"
else
puts "#{param}"
end
end
The above script result is following:
Filename
FileFormat
Password
WriteResPassword
ReadOnlyRecommended
CreateBackup
AccessMode (= 1)
ConflictResolution
AddToMru
TextCodepage
TextVisualLayout
# File 'ext/win32ole/win32ole_param.c', line 393
static VALUE foleparam_default(VALUE self) { struct oleparamdata *pparam; TypedData_Get_Struct(self, struct oleparamdata, &oleparam_datatype, pparam); return ole_param_default(pparam->pTypeInfo, pparam->method_index, pparam->index); }
#inspect ⇒ String
Returns the parameter name with class name. If the parameter has default value, then returns name=value string with class name.
# File 'ext/win32ole/win32ole_param.c', line 410
static VALUE foleparam_inspect(VALUE self) { VALUE detail = foleparam_name(self); VALUE defval = foleparam_default(self); if (defval != Qnil) { rb_str_cat2(detail, "="); rb_str_concat(detail, rb_inspect(defval)); } return make_inspect("WIN32OLE::Param", detail); }
#to_s
#name
Alias for #to_s.
#ole_type_detail
# File 'ext/win32ole/win32ole_param.c', line 231
static VALUE foleparam_ole_type_detail(VALUE self) { struct oleparamdata *pparam; TypedData_Get_Struct(self, struct oleparamdata, &oleparam_datatype, pparam); return ole_param_ole_type_detail(pparam->pTypeInfo, pparam->method_index, pparam->index); }
#to_s Also known as: #name
# File 'ext/win32ole/win32ole_param.c', line 166
static VALUE foleparam_name(VALUE self) { return rb_ivar_get(self, rb_intern("name")); }