2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/win32ole_helper.rb', line 2
def help(method_name)
method = ole_methods.find { |m| m.name.casecmp?(method_name.to_s) }
return "Method #{method_name} not found" unless method
params_info = method.params.map.with_index(1) do |param, i|
[
"Parameter #{i}: #{param.name}",
"Type: #{param.ole_type}",
"Direction: #{param.input? ? 'Input' : ''}#{param.output? ? 'Output' : ''}",
"Optional: #{param.optional? ? 'Yes' : 'No'}",
"Default: #{param.default if param.optional?}"
].compact.join("\n ")
end.join("\n\n")
tips = []
tips << "Contains VARIANT parameters - use WIN32OLE_VARIANT.new(value)" if method.params.any? { |p| p.ole_type == 'VARIANT' }
tips << "Has output parameters - returns [return_value, *outputs]" if method.params.any?(&:output?)
<<~HELP
Method: #{method.name}
Return Type: #{method.return_type}
Description: #{method.helpstring}
Parameters:
#{params_info}
#{tips.join("\n")}
HELP
end
|