Class: WIN32OLE_TYPE

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

Instance Attribute Summary collapse

Class Method 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_TYPE

Returns a new instance of WIN32OLE_TYPE.



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

def initialize(*args)
  case args.length
  when 2 then 
    typelib_name, olename = SafeStringValue(args[0]), SafeStringValue(args[1])
    @typelib = WIN32OLE_TYPELIB.new(typelib_name) # Internal call
    find_all_typeinfo(@typelib.typelib) do |info, docs|
      if (docs.name == olename)
        @typeinfo, @docs = info, docs
        break
      end
    end
    raise WIN32OLERuntimeError.new("not found `#{olename}` in `#{typelib_name}") unless @typeinfo
  when 3 then
    @typelib, @typeinfo, @docs = *args
  else
    raise ArgumentError.new("wrong number of arguments (#{args.length} for 2)")
  end
end

Instance Attribute Details

#typeinfoObject (readonly)

Returns the value of attribute typeinfo.



4
5
6
# File 'lib/win32ole/win32ole_type.rb', line 4

def typeinfo
  @typeinfo
end

Class Method Details

.ole_classes(tlib) ⇒ Object



144
145
146
# File 'lib/win32ole/win32ole_type.rb', line 144

def ole_classes(tlib)
  WIN32OLE_TYPELIB.ole_classes(tlib)
end

.progidsObject



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/win32ole/win32ole_type.rb', line 123

def progids
  array = []
  Win32::Registry::HKEY_CLASSES_ROOT.open('CLSID') do |reg|
    reg.each_key do |clsid, wtime|
      reg.open(clsid) do |clsid_reg|
        clsid_reg.each_key do |key, wtime|
          name = nil
          if key == "ProgID"
            clsid_reg.open(key) {|key_reg| name = key_reg.read(nil)[1] }
          end
          if !name && key == "VersionIndependentProgID"
            clsid_reg.open(key) {|key_reg| name = key_reg.read(nil)[1] }
          end
          array << name if name
        end
      end
    end
  end
  array
end

.typelibsObject

This is obsolete, but easy to emulate



119
120
121
# File 'lib/win32ole/win32ole_type.rb', line 119

def typelibs
  WIN32OLE_TYPELIB.typelibs.collect {|t| t.name }
end

Instance Method Details

#guidObject



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

def guid
  @typeinfo.guid
end

#helpcontextObject



29
30
31
# File 'lib/win32ole/win32ole_type.rb', line 29

def helpcontext
  @docs.help_context
end

#helpfileObject



37
38
39
# File 'lib/win32ole/win32ole_type.rb', line 37

def helpfile
  @docs.help_file
end

#helpstringObject



33
34
35
# File 'lib/win32ole/win32ole_type.rb', line 33

def helpstring
  @docs.doc_string
end

#major_versionObject



45
46
47
# File 'lib/win32ole/win32ole_type.rb', line 45

def major_version
  @typeinfo.major_version
end

#minor_versionObject



49
50
51
# File 'lib/win32ole/win32ole_type.rb', line 49

def minor_version
  @typeinfo.minor_version
end

#nameObject



41
42
43
# File 'lib/win32ole/win32ole_type.rb', line 41

def name
  @docs.name
end

#ole_methodsObject



53
54
55
56
57
58
59
60
# File 'lib/win32ole/win32ole_type.rb', line 53

def ole_methods
  members = []
  all_methods(@typeinfo) do |ti, oti, desc, docs, index|
    members << WIN32OLE_METHOD.new(self, ti, oti, desc, docs, index)
    nil
  end
  members
end

#ole_typeObject



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/win32ole/win32ole_type.rb', line 62

def ole_type
  case typekind
  when TypeInfo::TYPEKIND_ENUM then
    "Enum"
  when TypeInfo::TYPEKIND_RECORD then
    "Record"
  when TypeInfo::TYPEKIND_MODULE then
    "Module"
  when TypeInfo::TYPEKIND_INTERFACE then
    "Interface"
  when TypeInfo::TYPEKIND_DISPATCH then
    "Dispatch"
  when TypeInfo::TYPEKIND_COCLASS then
    "Class"
  when TypeInfo::TYPEKIND_ALIAS then
    "Alias"
  when TypeInfo::TYPEKIND_UNION then
    "Union"
  when TypeInfo::TYPEKIND_MAX then
    "Max"
  else
    nil
  end
end

#progidObject



87
88
89
# File 'lib/win32ole/win32ole_type.rb', line 87

def progid
  @typeinfo.progid
end

#src_typeObject



91
92
93
94
95
# File 'lib/win32ole/win32ole_type.rb', line 91

def src_type
  return nil if @typeinfo.typekind != TypeInfo::TYPEKIND_ALIAS

  typedesc_value @typeinfo.alias_vt
end

#to_sObject



97
98
99
# File 'lib/win32ole/win32ole_type.rb', line 97

def to_s
  name
end

#typekindObject



113
114
115
# File 'lib/win32ole/win32ole_type.rb', line 113

def typekind
  @typeinfo.typekind
end

#variablesObject



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

def variables
  variables = []
  all_vars(@typeinfo) do |desc, name|
    variables << WIN32OLE_VARIABLE.new(self, desc, name)
  end
  variables
end

#visible?Boolean

Returns:

  • (Boolean)


109
110
111
# File 'lib/win32ole/win32ole_type.rb', line 109

def visible?
  @typeinfo.flags & (TypeInfo::TYPEFLAG_FHIDDEN | TypeInfo::TYPEFLAG_FRESTRICTED) == 0
end