Class: AppMap::Trace::RubyMethod
- Defined in:
- lib/appmap/trace.rb
Instance Attribute Summary collapse
-
#class_name ⇒ Object
readonly
Returns the value of attribute class_name.
-
#static ⇒ Object
readonly
Returns the value of attribute static.
Class Method Summary collapse
-
.last_comment(file, line_number) ⇒ Object
Read file and get last comment before line.
Instance Method Summary collapse
- #comment ⇒ Object
-
#initialize(package, class_name, method, static) ⇒ RubyMethod
constructor
A new instance of RubyMethod.
- #labels ⇒ Object
- #name ⇒ Object
- #package ⇒ Object
- #source_location ⇒ Object
Constructor Details
#initialize(package, class_name, method, static) ⇒ RubyMethod
Returns a new instance of RubyMethod.
10 11 12 13 14 15 16 17 |
# File 'lib/appmap/trace.rb', line 10 def initialize(package, class_name, method, static) super(method) @package = package @class_name = class_name @method = method @static = static end |
Instance Attribute Details
#class_name ⇒ Object (readonly)
Returns the value of attribute class_name.
8 9 10 |
# File 'lib/appmap/trace.rb', line 8 def class_name @class_name end |
#static ⇒ Object (readonly)
Returns the value of attribute static.
8 9 10 |
# File 'lib/appmap/trace.rb', line 8 def static @static end |
Class Method Details
.last_comment(file, line_number) ⇒ Object
Read file and get last comment before line.
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/appmap/trace.rb', line 45 def self.last_comment(file, line_number) File.open(file) do |f| buffer = [] f.each_line.lazy.take(line_number - 1).reverse_each do |line| break unless (line =~ /^\s*#/) || (line =~ /^\s*$/) buffer << line.lstrip end buffer.reverse.join end end |
Instance Method Details
#comment ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/appmap/trace.rb', line 23 def comment return nil if source_location.nil? || source_location.first.start_with?("<") # Do not use method_source's comment method because it's slow @comment ||= RubyMethod.last_comment(*source_location) rescue Errno::EINVAL, Errno::ENOENT nil end |
#labels ⇒ Object
40 41 42 |
# File 'lib/appmap/trace.rb', line 40 def labels @package.labels end |
#name ⇒ Object
36 37 38 |
# File 'lib/appmap/trace.rb', line 36 def name @method.name end |
#package ⇒ Object
32 33 34 |
# File 'lib/appmap/trace.rb', line 32 def package @package.name end |
#source_location ⇒ Object
19 20 21 |
# File 'lib/appmap/trace.rb', line 19 def source_location @method.source_location end |