Class: HoptoadNotifier::Backtrace::Line
- Inherits:
-
Object
- Object
- HoptoadNotifier::Backtrace::Line
- Defined in:
- lib/hoptoad_notifier/backtrace.rb
Overview
Handles backtrace parsing line by line
Constant Summary collapse
- INPUT_FORMAT =
%r{^([^:]+):(\d+)(?::in `([^']+)')?$}.freeze
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
The file portion of the line (such as app/models/user.rb).
-
#method ⇒ Object
readonly
The method 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) ⇒ 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) ⇒ Line
Returns a new instance of Line.
27 28 29 30 31 |
# File 'lib/hoptoad_notifier/backtrace.rb', line 27 def initialize(file, number, method) self.file = file self.number = number self.method = method end |
Instance Attribute Details
#file ⇒ Object
The file portion of the line (such as app/models/user.rb)
11 12 13 |
# File 'lib/hoptoad_notifier/backtrace.rb', line 11 def file @file end |
#method ⇒ Object
The method of the line (such as index)
17 18 19 |
# File 'lib/hoptoad_notifier/backtrace.rb', line 17 def method @method end |
#number ⇒ Object
The line number portion of the line
14 15 16 |
# File 'lib/hoptoad_notifier/backtrace.rb', line 14 def number @number end |
Class Method Details
.parse(unparsed_line) ⇒ Line
Parses a single line of a given backtrace
22 23 24 25 |
# File 'lib/hoptoad_notifier/backtrace.rb', line 22 def self.parse(unparsed_line) _, file, number, method = unparsed_line.match(INPUT_FORMAT).to_a new(file, number, method) end |
Instance Method Details
#==(other) ⇒ Object
38 39 40 |
# File 'lib/hoptoad_notifier/backtrace.rb', line 38 def ==(other) to_s == other.to_s end |
#inspect ⇒ Object
42 43 44 |
# File 'lib/hoptoad_notifier/backtrace.rb', line 42 def inspect "<Line:#{to_s}>" end |
#to_s ⇒ Object
Reconstructs the line in a readable fashion
34 35 36 |
# File 'lib/hoptoad_notifier/backtrace.rb', line 34 def to_s "#{file}:#{number}:in `#{method}'" end |