Class: Betterp::Source
- Inherits:
-
Object
- Object
- Betterp::Source
- Defined in:
- lib/betterp/source.rb
Overview
Parses a line from a stack trace to generate file path, line number, and method name.
Instance Method Summary collapse
-
#initialize(source, base_path) ⇒ Source
constructor
A new instance of Source.
- #line_no ⇒ Object
- #method_name ⇒ Object
- #path ⇒ Object
Constructor Details
#initialize(source, base_path) ⇒ Source
Returns a new instance of Source.
6 7 8 9 10 |
# File 'lib/betterp/source.rb', line 6 def initialize(source, base_path) @source = source @base_path = base_path @path, @line_no, @method_info = source.split(':') end |
Instance Method Details
#line_no ⇒ Object
18 19 20 |
# File 'lib/betterp/source.rb', line 18 def line_no @line_no.to_i end |
#method_name ⇒ Object
22 23 24 |
# File 'lib/betterp/source.rb', line 22 def method_name @method_info.partition('`').last.chomp("'") end |
#path ⇒ Object
12 13 14 15 16 |
# File 'lib/betterp/source.rb', line 12 def path Pathname.new(@path).relative_path_from(Pathname.new(@base_path)).to_s rescue ArgumentError @path end |