Class: PryExceptionExplorer::LazyFrame

Inherits:
Object
  • Object
show all
Defined in:
lib/pry-exception_explorer/lazy_frame.rb

Defined Under Namespace

Classes: NullFrame

Constant Summary

START_FRAME_OFFSET =

we need to jump over a few irrelevant frames to begin with

6

Instance Method Summary collapse

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

#klassClass

Returns The class of the self of the frame.

Returns:

  • (Class)

    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_nameSymbol?

Returns The name of the active method in the frame (or nil)

Returns:

  • (Symbol, nil)

    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

#prevLazyFrame

Returns The caller frame.

Returns:



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

#selfObject

Returns The object context of the frame (the self).

Returns:

  • (Object)

    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