Class: WIN32OLE

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/win32ole/win32ole_ruby.rb,
lib/win32ole/utils.rb,
lib/win32ole/win32ole_variant.rb

Overview

Shorthand vocabulary:

ti, oti - typeinfo or owner_typeinfo

Defined Under Namespace

Modules: Utils, VARIANT

Constant Summary collapse

CP_ACP =
0
CP_OEMCP =
1
CP_MACCP =
2
CP_THREAD_ACP =
3
CP_SYMBOL =
42
CP_UTF7 =
65000
CP_UTF8 =
65001

Class Method Summary collapse

Instance Method Summary collapse

Methods included from 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

Class Method Details

.codepageObject



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

def codepage
  @@codepage ||= CP_ACP
end

.codepage=(new_codepage) ⇒ Object



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

def codepage=(new_codepage)
  @@codepage = new_codepage
end

.connect(id) ⇒ Object



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

def connect(id)
  WIN32OLE.new to_progid(id)
end

.const_load(ole, a_class = WIN32OLE) ⇒ Object



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

def const_load(ole, a_class=WIN32OLE)
  constants = {}
  ole.type_info.containing_type_lib.type_info.to_a.each do |info|
    info.vars_count.times do |i|
      var_desc = info.get_var_desc(i)
      # TODO: Missing some additional flag checks to limit no. of constants
      if var_desc.constant
        name = first_var_name(info, var_desc)
        name = name[0].chr.upcase + name[1..-1] if name
        if constant?(name)
          a_class.const_set name, RubyWIN32OLE.from_variant(JRuby.runtime, var_desc.constant)
        else # vars which don't start [A-Z]?
          constants[name] = var_desc.constant
        end
      end
    end
  end
  a_class.const_set 'CONSTANTS', constants
  nil
end

.to_progid(id) ⇒ Object



95
96
97
# File 'lib/win32ole/win32ole_ruby.rb', line 95

def to_progid(id)
  id =~ /^{(.*)}/ ? "clsid:#{$1}" : id
end

Instance Method Details

#ole_func_methodsObject



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

def ole_func_methods
  methods_with_flag(Dispatch::Method)
end

#ole_get_methodsObject



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

def ole_get_methods
  methods_with_flag(Dispatch::Get)
end

#ole_method(name) ⇒ Object Also known as: ole_method_help



16
17
18
19
20
21
# File 'lib/win32ole/win32ole_ruby.rb', line 16

def ole_method(name)
  all_methods(typeinfo_from_ole) do |*args|
    return WIN32OLE_METHOD.new(nil, *args) if name == args[3].name
    nil
  end
end

#ole_methodsObject



24
25
26
27
28
29
30
31
# File 'lib/win32ole/win32ole_ruby.rb', line 24

def ole_methods
  members = []
  all_methods(typeinfo_from_ole) do |*args|
    members << WIN32OLE_METHOD.new(nil, *args)
    nil
  end
  members
end

#ole_put_methodsObject



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

def ole_put_methods
  methods_with_flag(Dispatch::Put|Dispatch::PutRef)
end

#ole_typeObject Also known as: ole_obj_help



45
46
47
48
49
# File 'lib/win32ole/win32ole_ruby.rb', line 45

def ole_type
  typelib = type_info.containing_type_lib
  docs = typelib.documentation(typelib.index)
  WIN32OLE_TYPE.new typelib, type_info, docs
end

#ole_typelibObject



52
53
54
55
# File 'lib/win32ole/win32ole_ruby.rb', line 52

def ole_typelib
  typelib = type_info.containing_type_lib
  WIN32OLE_TYPELIB.new typelib, nil
end

#type_infoObject



57
58
59
# File 'lib/win32ole/win32ole_ruby.rb', line 57

def type_info
  dispatch.type_info
end