Class: Pry::LastException
- Inherits:
-
BasicObject
- Defined in:
- lib/pry/last_exception.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
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
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
37
38
39
|
# File 'lib/pry/last_exception.rb', line 37
def file
@file
end
|
#line ⇒ Fixnum
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
48
49
50
|
# File 'lib/pry/last_exception.rb', line 48
def wrapped_exception
@exception
end
|