Class: PryMoves::Iterate

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

Instance Method Summary collapse

Methods inherited from TraceCommand

#initialize, #start_tracing, #stop_tracing, trace, #trace_obj, #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
6
7
# File 'lib/commands/iterate.rb', line 3

def init(binding_)
  @iteration_start_line = binding_.eval('__LINE__')
  @caller_digest = frame_digest(binding_)
  @receiver = binding_.receiver
end

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



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/commands/iterate.rb', line 9

def trace(event, file, line, method, binding_)
  return true if event == 'return' and
    traced_method?(file, line, method, binding_)

  # промотка итерации -
  # попасть на ту же или предыдущую строку или выйти из дайджеста
  # будучи в том же методе
  event == 'line' and @call_depth == 0 and
    traced_method?(file, line, method, binding_) and
    (line <= @iteration_start_line or
      @caller_digest != current_frame_digest
    )
end

#traced_method?(file, line, method, binding_) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/commands/iterate.rb', line 23

def traced_method?(file, line, method, binding_)
  super and @receiver == binding_.receiver
end