22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/xiki/ruby.rb', line 22
def self.classes clazz=nil, method=nil
if clazz.nil?
result = []
ObjectSpace.each_object(Class) do |c|
name = c.to_s
next if name =~ /^#/
result << "- #{name}/\n"
end
return result.sort.join
end
if method.nil?
result = ""
result << Kernel.const_get(clazz).instance_methods(false).sort.
collect {|i| "- #{i}/" }.join("\n")
result << Kernel.const_get(clazz).methods(false).sort.
collect {|i| "- ::#{i}/" }.join("\n")
return result
end
method = "##{method}" unless method =~ /^::/
command = "qri #{clazz}#{method}"
Console[command].gsub(/\C-[.+?m/, '').gsub(/^/, '| ').gsub(/^\| +$/, '|')
end
|