Class: WIN32OLE_METHOD

Inherits:
Object
  • Object
show all
Includes:
WIN32OLE::Utils
Defined in:
lib/win32ole/win32ole_method.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from WIN32OLE::Utils

#SafeStringValue, #WIN32OLE_TYPEValue, #all_methods, #all_vars, #find_all_methods_in, #find_all_typeinfo, #load_typelib, #methods_with_flag, #reg_each_key_for, #registry_subkey, #search_registry, #typedesc_value, #typeinfo_from_ole, #typelib_registry_each_guid_version

Constructor Details

#initialize(*args) ⇒ WIN32OLE_METHOD

Returns a new instance of WIN32OLE_METHOD.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/win32ole/win32ole_method.rb', line 7

def initialize(*args)
  # TODO: 2-arg missing currently unuised oletype ivar
  if args.length == 6 # Internal initializer
    @oletype,  @typeinfo, @owner_typeinfo, @desc, @docs, @index = *args
  elsif args.length == 2 # Normal constructor
    @oletype, name = WIN32OLE_TYPEValue(args[0]), SafeStringValue(args[1])
    all_methods(@oletype.typeinfo) do |ti, oti, desc, docs, index|
      if docs.name.downcase == name.downcase
        @typeinfo, @owner_typeinfo, @desc, @docs, @index = ti, oti, desc, docs, index
        break;
      end
    end
    raise WIN32OLERuntimeError.new "not found: #{name}" if !@typeinfo
  else # Error
    raise ArgumentError.new("2 for #{args.length}")
  end
end

Instance Attribute Details

#oletypeObject

Returns the value of attribute oletype.



5
6
7
# File 'lib/win32ole/win32ole_method.rb', line 5

def oletype
  @oletype
end

#typeinfoObject

Returns the value of attribute typeinfo.



5
6
7
# File 'lib/win32ole/win32ole_method.rb', line 5

def typeinfo
  @typeinfo
end

Instance Method Details

#dispidObject



25
26
27
# File 'lib/win32ole/win32ole_method.rb', line 25

def dispid
  @desc.memid
end

#event?Boolean

Returns:

  • (Boolean)


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/win32ole/win32ole_method.rb', line 29

def event?
  return false if @owner_typeinfo.typekind != TypeInfo::TYPEKIND_COCLASS

  @owner_typeinfo.impl_types_count.times do |i|
    begin
      flags = @owner_typeinfo.get_impl_type_flags(i)

      if flags & TypeInfo::IMPLTYPEFLAG_FSOURCE
        href = @owner_typeinfo.get_ref_type_of_impl_type(i)
        ref_typeinfo = @owner_typeinfo.get_ref_type_info(href)
        func_desc = ref_typeinfo.func_desc(@index)
        documentation = ref_typeinfo.documentation(func_desc.memid)

        return true if documentation.name == name
      end
    rescue ComFailException => e
    end
  end
  false
end

#event_interfaceObject



50
51
52
53
54
55
56
# File 'lib/win32ole/win32ole_method.rb', line 50

def event_interface
  return nil unless event?

  typelib = @typeinfo.containing_type_lib
  documentation = typelib.documentation(typelib.index)
  documentation.name
end

#helpcontextObject



58
59
60
# File 'lib/win32ole/win32ole_method.rb', line 58

def helpcontext
  @docs.help_context
end

#helpfileObject



66
67
68
# File 'lib/win32ole/win32ole_method.rb', line 66

def helpfile
  @docs.help_file
end

#helpstringObject



62
63
64
# File 'lib/win32ole/win32ole_method.rb', line 62

def helpstring
  @docs.doc_string
end

#inspectObject



133
134
135
# File 'lib/win32ole/win32ole_method.rb', line 133

def inspect
  name
end

#invkindObject



70
71
72
# File 'lib/win32ole/win32ole_method.rb', line 70

def invkind
  @desc.invkind
end

#invoke_kindObject



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/win32ole/win32ole_method.rb', line 74

def invoke_kind
  invkind = @desc.invkind
  if invkind & Dispatch::Get && invkind & Dispatch::Put
    return "PROPERTY"
  elsif invkind & Dispatch::Get
    return "PROPERTYGET"
  elsif invkind & Dispatch::Put
    return "PROPERTYPUT"
  elsif invkind & Dispatch::PutRef
    return "PROPERTYPUTREF"
  elsif invkind & Dispatch::Method
    return "FUNC"
  else
    return "UNKOWN"
  end
end

#nameObject Also known as: to_s



91
92
93
# File 'lib/win32ole/win32ole_method.rb', line 91

def name
  @docs.name
end

#offset_vtblObject



96
97
98
# File 'lib/win32ole/win32ole_method.rb', line 96

def offset_vtbl
  @desc.vtable_offset
end

#paramsObject



100
101
102
103
104
105
106
# File 'lib/win32ole/win32ole_method.rb', line 100

def params
  arr = []
  @desc.parameters.to_a.each_with_index do |param, i|
    arr << WIN32OLE_PARAM.new(self, i, param)
  end
  arr
end

#return_typeObject



108
109
110
# File 'lib/win32ole/win32ole_method.rb', line 108

def return_type
  typedesc_value(@desc.return_type.vt)
end

#return_type_detailObject



112
113
114
# File 'lib/win32ole/win32ole_method.rb', line 112

def return_type_detail
  typedesc_value(@desc.return_type.vt, [])
end

#return_vtypeObject



116
117
118
# File 'lib/win32ole/win32ole_method.rb', line 116

def return_vtype
  @desc.return_type.vt
end

#size_opt_paramsObject



120
121
122
# File 'lib/win32ole/win32ole_method.rb', line 120

def size_opt_params
  @desc.opt_params_count
end

#size_paramsObject



124
125
126
# File 'lib/win32ole/win32ole_method.rb', line 124

def size_params
  @desc.params_count
end

#visible?Boolean

Returns:

  • (Boolean)


128
129
130
131
# File 'lib/win32ole/win32ole_method.rb', line 128

def visible?
  (@desc.flags & (FuncDesc::FUNCFLAG_FRESTRICTED | FuncDesc::FUNCFLAG_FHIDDEN |
    FuncDesc::FUNCFLAG_FNONBROWSABLE)) == 0
end