Class: ObjectTracker::TrackerMethod
- Inherits:
-
Object
- Object
- ObjectTracker::TrackerMethod
- Defined in:
- lib/object_tracker/tracker_method.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #display_name ⇒ Object
-
#initialize(context, name) ⇒ TrackerMethod
constructor
A new instance of TrackerMethod.
- #source ⇒ Object
- #source_location ⇒ Object
Constructor Details
#initialize(context, name) ⇒ TrackerMethod
Returns a new instance of TrackerMethod.
5 6 7 8 |
# File 'lib/object_tracker/tracker_method.rb', line 5 def initialize(context, name) @name = name @context = context end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
3 4 5 |
# File 'lib/object_tracker/tracker_method.rb', line 3 def context @context end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/object_tracker/tracker_method.rb', line 3 def name @name end |
Instance Method Details
#display_name ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/object_tracker/tracker_method.rb', line 21 def display_name return @display_name if defined? @display_name if Class === context || Module === context obj = context prefix = '.' elsif context.class === Class prefix = '.' obj = context.class else prefix = '#' obj = context.class end @display_name = "#{obj.name}#{prefix}#{@name}" end |
#source ⇒ Object
10 11 12 13 14 |
# File 'lib/object_tracker/tracker_method.rb', line 10 def source return @source if defined? @source @source = source_location @source = @source ? @source.join(':').split('/').last(5).join('/') : 'RUBY CORE' end |
#source_location ⇒ Object
16 17 18 19 |
# File 'lib/object_tracker/tracker_method.rb', line 16 def source_location method_handle = context.method(name) method_handle.source_location if method_handle end |