Class: Airbrake::Backtrace::Line
- Inherits:
-
Object
- Object
- Airbrake::Backtrace::Line
- Defined in:
- lib/airbrake/backtrace.rb
Overview
Handles backtrace parsing line by line
Constant Summary collapse
- INPUT_FORMAT =
regexp (optionnally allowing leading X: for windows support)
%r{^((?:[a-zA-Z]:)?[^:]+):(\d+)(?::in `([^']+)')?$}.freeze
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
The file portion of the line (such as app/models/user.rb).
-
#method_name ⇒ Object
readonly
The method_name of the line (such as index).
-
#number ⇒ Object
readonly
The line number portion of the line.
Class Method Summary collapse
-
.parse(unparsed_line) ⇒ Line
Parses a single line of a given backtrace.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(file, number, method_name) ⇒ Line
constructor
A new instance of Line.
- #inspect ⇒ Object
-
#to_s ⇒ Object
Reconstructs the line in a readable fashion.
Constructor Details
#initialize(file, number, method_name) ⇒ Line
Returns a new instance of Line.
28 29 30 31 32 |
# File 'lib/airbrake/backtrace.rb', line 28 def initialize(file, number, method_name) @file = file @number = number @method_name = method_name end |
Instance Attribute Details
#file ⇒ Object (readonly)
The file portion of the line (such as app/models/user.rb)
12 13 14 |
# File 'lib/airbrake/backtrace.rb', line 12 def file @file end |
#method_name ⇒ Object (readonly)
The method_name of the line (such as index)
18 19 20 |
# File 'lib/airbrake/backtrace.rb', line 18 def method_name @method_name end |
#number ⇒ Object (readonly)
The line number portion of the line
15 16 17 |
# File 'lib/airbrake/backtrace.rb', line 15 def number @number end |
Class Method Details
.parse(unparsed_line) ⇒ Line
Parses a single line of a given backtrace
23 24 25 26 |
# File 'lib/airbrake/backtrace.rb', line 23 def self.parse(unparsed_line) _, file, number, method_name = unparsed_line.match(INPUT_FORMAT).to_a new(file, number, method_name) end |
Instance Method Details
#==(other) ⇒ Object
39 40 41 |
# File 'lib/airbrake/backtrace.rb', line 39 def ==(other) to_s == other.to_s end |
#inspect ⇒ Object
43 44 45 |
# File 'lib/airbrake/backtrace.rb', line 43 def inspect "<Line:#{to_s}>" end |
#to_s ⇒ Object
Reconstructs the line in a readable fashion
35 36 37 |
# File 'lib/airbrake/backtrace.rb', line 35 def to_s "#{file}:#{number}:in `#{method_name}'" end |