Class: Codebeacon::Tracer::TPKlass

Inherits:
Object
  • Object
show all
Defined in:
lib/codebeacon/tracer/src/models/tpklass.rb

Instance Method Summary collapse

Constructor Details

#initialize(tp) ⇒ TPKlass

Returns a new instance of TPKlass.



4
5
6
# File 'lib/codebeacon/tracer/src/models/tpklass.rb', line 4

def initialize(tp)
  @tp = tp
end

Instance Method Details

#defined_classObject



16
17
18
19
20
21
22
23
24
25
# File 'lib/codebeacon/tracer/src/models/tpklass.rb', line 16

def defined_class
  klass = @tp.defined_class.to_s.sub("#<", "").sub(">", "")
  if klass.match(/^(Class|Module):/)
    klass = klass.split(":")[1..].join(":")
  elsif klass.match(/:0x[0-9a-f]+$/)
    klass = klass.split(":")[0..-2].join(":")
    klass += " Singleton"
  end
  klass
end

#tp_classObject



8
9
10
11
12
13
14
# File 'lib/codebeacon/tracer/src/models/tpklass.rb', line 8

def tp_class
  klass = @tp.self.class
  while klass && klass.to_s =~ /Class:0x/
    klass = klass.superclass
  end
  klass
end

#tp_class_nameObject



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/codebeacon/tracer/src/models/tpklass.rb', line 27

def tp_class_name
  if @tp.self.is_a?(Module)
    @tp.self.name
  else
    klass = @tp.self.class
    while klass && klass.to_s =~ /Class:0x/
      klass = klass.superclass
    end
    klass.name
  end
end

#typeObject



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/codebeacon/tracer/src/models/tpklass.rb', line 39

def type
  case @tp.self
  when Class
    :Class
  when Module
    :Module
  when Object
    :Object
  else
    :Unknown
  end
end