Class: PrivatePlease::Tracking::TracePointDetails

Inherits:
Struct
  • Object
show all
Defined in:
lib/private_please/tracking/trace_point_details.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#_selfObject

Returns the value of attribute _self

Returns:

  • (Object)

    the current value of _self



3
4
5
# File 'lib/private_please/tracking/trace_point_details.rb', line 3

def _self
  @_self
end

#defined_classObject

Returns the value of attribute defined_class

Returns:

  • (Object)

    the current value of defined_class



3
4
5
# File 'lib/private_please/tracking/trace_point_details.rb', line 3

def defined_class
  @defined_class
end

#eventObject

Returns the value of attribute event

Returns:

  • (Object)

    the current value of event



3
4
5
# File 'lib/private_please/tracking/trace_point_details.rb', line 3

def event
  @event
end

#linenoObject

Returns the value of attribute lineno

Returns:

  • (Object)

    the current value of lineno



3
4
5
# File 'lib/private_please/tracking/trace_point_details.rb', line 3

def lineno
  @lineno
end

#method_idObject

Returns the value of attribute method_id

Returns:

  • (Object)

    the current value of method_id



3
4
5
# File 'lib/private_please/tracking/trace_point_details.rb', line 3

def method_id
  @method_id
end

#object_idObject

Returns the value of attribute object_id

Returns:

  • (Object)

    the current value of object_id



3
4
5
# File 'lib/private_please/tracking/trace_point_details.rb', line 3

def object_id
  @object_id
end

#pathObject

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



3
4
5
# File 'lib/private_please/tracking/trace_point_details.rb', line 3

def path
  @path
end

Class Method Details

.from(tp) ⇒ Object



4
5
6
# File 'lib/private_please/tracking/trace_point_details.rb', line 4

def self.from(tp)
  new(tp.event, tp.self.object_id, tp.path, tp.lineno, tp.defined_class, tp.method_id, tp.self)
end

Instance Method Details

#codeObject



12
13
14
# File 'lib/private_please/tracking/trace_point_details.rb', line 12

def code
  @_code ||= File.readlines(path)[lineno - 1].chomp
end

#method_full_nameObject

Combine the class and method name with the proper separator Examples:

Array#new
Array.size


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/private_please/tracking/trace_point_details.rb', line 20

def method_full_name
  defined_class_s = defined_class.to_s
  is_module_class_method = defined_class_s.start_with?('#<Class:')
  if is_module_class_method
    defined_class_s.gsub!(/^#<Class:/, '').delete!('>')
    "#{defined_class_s}.#{method_id}"
  elsif module_method?
    "#{defined_class}##{method_id}"
  else
    instance_method = !(_self.class == Class)
    instance_method ?
        "#{defined_class}##{method_id}" :
        "#{_self}.#{method_id}"
  end
end

#same_object?(other) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/private_please/tracking/trace_point_details.rb', line 8

def same_object?(other)
  object_id == other.object_id
end