Class: Method

Inherits:
Object show all
Defined in:
lib/irt/extensions/method.rb

Instance Method Summary collapse

Instance Method Details

#infoObject



33
34
35
36
37
38
39
40
# File 'lib/irt/extensions/method.rb', line 33

def info
  file, line = location
  { :name  => name,
    :owner => owner.name,
    :file  => file,
    :line  => line,
    :arity => arity }
end

#locationObject



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
31
# File 'lib/irt/extensions/method.rb', line 3

def location
  f = l = nil
  n = case
      when arity >= 0
        arity
      when arity == -1
        0
      when arity < -1
        arity.abs - 1
      end
  arr = Array.new(n)
  set_trace_func proc{ |event, file, line, meth_name, binding, classname|
    if name == meth_name
      case event
      when 'call'
        f = file
        l = line
        throw :method_located
     when 'c-call'
        f = "(c-func)"
        throw :method_located
      end
    end
  }
  catch(:method_located) { call *arr }
  [f,l]
ensure
  set_trace_func nil
end