class CodeMapper::Filter::MaxDepth

Public Class Methods

new(max_depth) click to toggle source
# File lib/code_mapper/filter/max_depth.rb, line 4
def initialize(max_depth)
  @max_depth = max_depth
  @depth = 0
end

Public Instance Methods

keep?(tp, _) click to toggle source
# File lib/code_mapper/filter/max_depth.rb, line 9
def keep?(tp, _)
  if call_event?(tp)
    @depth += 1
    return false if @depth > @max_depth
  elsif return_event?(tp)
    old_depth = @depth
    @depth -= 1
    return false if old_depth > @max_depth
  end

  true
end

Private Instance Methods

call_event?(tp) click to toggle source
# File lib/code_mapper/filter/max_depth.rb, line 24
def call_event?(tp)
  tp.event == :call || tp.event == :c_call
end
return_event?(tp) click to toggle source
# File lib/code_mapper/filter/max_depth.rb, line 28
def return_event?(tp)
  tp.event == :return || tp.event == :c_return
end