Class: Pry::LastException
- Inherits:
- BasicObject
- Defined in:
- lib/pry/last_exception.rb
Instance Attribute Summary collapse
-
#bt_index ⇒ Object
Returns the value of attribute bt_index.
-
#file ⇒ String
readonly
Returns the path to a file for the current backtrace.
-
#line ⇒ Fixnum
readonly
Returns the line for the current backtrace.
Instance Method Summary collapse
- #bt_source_location_for(index) ⇒ Object
- #inc_bt_index ⇒ Object
-
#initialize(exception) ⇒ LastException
constructor
A new instance of LastException.
- #method_missing(name, *args, &block) ⇒ Object
- #respond_to_missing?(name, include_all = false) ⇒ Boolean
-
#wrapped_exception ⇒ Exception
Returns the wrapped exception.
Constructor Details
#initialize(exception) ⇒ LastException
Returns a new instance of LastException.
15 16 17 18 19 |
# File 'lib/pry/last_exception.rb', line 15 def initialize(exception) @exception = exception @bt_index = 0 @file, @line = bt_source_location_for(0) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/pry/last_exception.rb', line 21 def method_missing(name, *args, &block) if @exception.respond_to?(name) @exception.public_send(name, *args, &block) else super end end |
Instance Attribute Details
#bt_index ⇒ Object
Returns the value of attribute bt_index.
13 14 15 |
# File 'lib/pry/last_exception.rb', line 13 def bt_index @bt_index end |
#file ⇒ String (readonly)
Returns the path to a file for the current backtrace. see #bt_index.
37 38 39 |
# File 'lib/pry/last_exception.rb', line 37 def file @file end |
#line ⇒ Fixnum (readonly)
Returns the line for the current backtrace. see #bt_index.
43 44 45 |
# File 'lib/pry/last_exception.rb', line 43 def line @line end |
Instance Method Details
#bt_source_location_for(index) ⇒ Object
52 53 54 55 |
# File 'lib/pry/last_exception.rb', line 52 def bt_source_location_for(index) backtrace[index] =~ /(.*):(\d+)/ [::Regexp.last_match(1), ::Regexp.last_match(2).to_i] end |
#inc_bt_index ⇒ Object
57 58 59 |
# File 'lib/pry/last_exception.rb', line 57 def inc_bt_index @bt_index = (@bt_index + 1) % backtrace.size end |
#respond_to_missing?(name, include_all = false) ⇒ Boolean
29 30 31 |
# File 'lib/pry/last_exception.rb', line 29 def respond_to_missing?(name, include_all = false) @exception.respond_to?(name, include_all) end |
#wrapped_exception ⇒ Exception
Returns the wrapped exception
48 49 50 |
# File 'lib/pry/last_exception.rb', line 48 def wrapped_exception @exception end |