Class: PryMoves::Finish

Inherits:
TraceCommand show all
Defined in:
lib/commands/finish.rb

Instance Method Summary collapse

Methods inherited from TraceCommand

#initialize, #start_tracing, #stop_tracing, trace, #trace_obj, #traced_method?, #tracing_func

Methods included from TraceHelpers

#current_frame_digest, #current_frame_type, #debug_info, #frame_digest, #frame_type, #redirect_step?

Constructor Details

This class inherits a constructor from PryMoves::TraceCommand

Instance Method Details

#init(binding_) ⇒ Object



3
4
5
# File 'lib/commands/finish.rb', line 3

def init(binding_)
  @block_to_finish = frame_digest(binding_) if binding_.frame_type == :block
end

#trace(event, file, line, method, binding_) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/commands/finish.rb', line 7

def trace(event, file, line, method, binding_)
  return true if @on_exit_from_method
  return if @call_depth > 0 or event == 'c-return'

  return true if @call_depth < 0

  # early return:
  return true if event == 'return' and
    @call_depth == 0 and @method.within?(file, line) and
    method == @method[:name] and @method.before_end?(line)

  # for finishing blocks inside current method
  if @block_to_finish
    ((@call_depth == 0) ^ (event == 'return')) and
      @method.within?(file, line) and
      @block_to_finish != current_frame_digest
  end
end