Class: PryExceptionExplorer::LazyFrame
- Defined in:
- lib/pry-exception_explorer/lazy_frame.rb
Defined Under Namespace
Classes: NullFrame
Constant Summary collapse
- START_FRAME_OFFSET =
we need to jump over a few irrelevant frames to begin with
6
Instance Method Summary collapse
-
#initialize(frame, frame_counter = 0, call_stack = nil) ⇒ LazyFrame
constructor
A new instance of LazyFrame.
-
#klass ⇒ Class
The class of the
self
of the frame. -
#method_name ⇒ Symbol?
The name of the active method in the frame (or
nil
). -
#prev ⇒ LazyFrame
The caller frame.
-
#self ⇒ Object
The object context of the frame (the
self
).
Constructor Details
#initialize(frame, frame_counter = 0, call_stack = nil) ⇒ LazyFrame
Returns a new instance of LazyFrame.
13 14 15 16 17 |
# File 'lib/pry-exception_explorer/lazy_frame.rb', line 13 def initialize(frame, frame_counter = 0, call_stack = nil) @frame = frame @frame_counter = frame_counter @call_stack = call_stack end |
Instance Method Details
#klass ⇒ Class
Returns The class of the self
of the frame.
20 21 22 |
# File 'lib/pry-exception_explorer/lazy_frame.rb', line 20 def klass @frame.eval("self.class") end |
#method_name ⇒ Symbol?
Returns The name of the active method in the frame (or nil
).
30 31 32 |
# File 'lib/pry-exception_explorer/lazy_frame.rb', line 30 def method_name @frame.eval("__method__") end |
#prev ⇒ LazyFrame
Returns The caller frame.
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/pry-exception_explorer/lazy_frame.rb', line 35 def prev if @call_stack if @frame_counter < (@call_stack.size - 1) LazyFrame.new(@call_stack[@frame_counter + 1], @frame_counter + 1, @call_stack) else NullFrame.new end else LazyFrame.new(binding.of_caller(@frame_counter + START_FRAME_OFFSET), @frame_counter + 1) end end |
#self ⇒ Object
Returns The object context of the frame (the self
).
25 26 27 |
# File 'lib/pry-exception_explorer/lazy_frame.rb', line 25 def self @frame.eval("self") end |