Class: SCNR::Introspector::ExecutionFlow::Point
- Inherits:
-
Object
- Object
- SCNR::Introspector::ExecutionFlow::Point
- Defined in:
- lib/scnr/introspector/execution_flow/point.rb
Overview
Trace point, similar in function to a native Ruby TracePoint. Points to a code execution #event.
Instance Attribute Summary collapse
-
#class_name ⇒ String
Class name containing the point.
-
#event ⇒ Symbol
Event name.
-
#line_number ⇒ Integer?
File line number, ‘nil` if no file is available (i.e. compiled code).
-
#method_name ⇒ Symbol
Name of method associated with the #event.
-
#path ⇒ String?
Path to the source file, ‘nil` if no file is available (i.e. compiled code).
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Point
constructor
A new instance of Point.
- #inspect ⇒ Object
- #marshal_dump ⇒ Object
- #marshal_load(h) ⇒ Object
- #to_rpc_data ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Point
Returns a new instance of Point.
30 31 32 33 34 35 36 |
# File 'lib/scnr/introspector/execution_flow/point.rb', line 30 def initialize( = {} ) .each do |k, v| next if v.nil? send( "#{k}=", v ) end end |
Instance Attribute Details
#class_name ⇒ String
Returns Class name containing the point.
19 20 21 |
# File 'lib/scnr/introspector/execution_flow/point.rb', line 19 def class_name @class_name end |
#event ⇒ Symbol
Returns Event name.
27 28 29 |
# File 'lib/scnr/introspector/execution_flow/point.rb', line 27 def event @event end |
#line_number ⇒ Integer?
Returns File line number, ‘nil` if no file is available (i.e. compiled code).
15 16 17 |
# File 'lib/scnr/introspector/execution_flow/point.rb', line 15 def line_number @line_number end |
#method_name ⇒ Symbol
Returns Name of method associated with the #event.
23 24 25 |
# File 'lib/scnr/introspector/execution_flow/point.rb', line 23 def method_name @method_name end |
#path ⇒ String?
Returns Path to the source file, ‘nil` if no file is available (i.e. compiled code).
11 12 13 |
# File 'lib/scnr/introspector/execution_flow/point.rb', line 11 def path @path end |
Class Method Details
.from_rpc_data(data) ⇒ Object
57 58 59 60 61 |
# File 'lib/scnr/introspector/execution_flow/point.rb', line 57 def self.from_rpc_data( data ) n = self.new n.marshal_load( data ) n end |
.from_trace_point(tp) ⇒ Point
69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/scnr/introspector/execution_flow/point.rb', line 69 def from_trace_point( tp ) defined_class = (tp.defined_class.is_a?( Class ) || tp.defined_class.is_a?( Module ) ? tp.defined_class.name : tp.defined_class.class.name) new({ path: tp.path, line_number: tp.lineno, class_name: defined_class, method_name: tp.method_id, event: tp.event }) end |
Instance Method Details
#inspect ⇒ Object
38 39 40 |
# File 'lib/scnr/introspector/execution_flow/point.rb', line 38 def inspect "#{path}:#{line_number} #{class_name}##{method_name} #{event}" end |
#marshal_dump ⇒ Object
42 43 44 45 46 47 |
# File 'lib/scnr/introspector/execution_flow/point.rb', line 42 def marshal_dump instance_variables.inject( {} ) do |h, iv| h[iv.to_s.gsub('@','')] = instance_variable_get( iv ) h end end |
#marshal_load(h) ⇒ Object
49 50 51 |
# File 'lib/scnr/introspector/execution_flow/point.rb', line 49 def marshal_load( h ) h.each { |k, v| instance_variable_set( "@#{k}", v ) } end |
#to_rpc_data ⇒ Object
53 54 55 |
# File 'lib/scnr/introspector/execution_flow/point.rb', line 53 def to_rpc_data marshal_dump end |