Class: RuboCop::AST::NodePattern::Compiler::Debug::Trace

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/ast/node_pattern/compiler/debug.rb

Overview

Compiled node pattern requires a named parameter `trace`, which should be an instance of this class

Instance Method Summary collapse

Constructor Details

#initializeTrace

Returns a new instance of Trace.


14
15
16
# File 'lib/rubocop/ast/node_pattern/compiler/debug.rb', line 14

def initialize
  @visit = {}
end

Instance Method Details

#enter(node_id) ⇒ Object


18
19
20
21
# File 'lib/rubocop/ast/node_pattern/compiler/debug.rb', line 18

def enter(node_id)
  @visit[node_id] = false
  true
end

#matched?(node_id) ⇒ Boolean

return nil (not visited), false (not matched) or true (matched)

Returns:

  • (Boolean)

28
29
30
# File 'lib/rubocop/ast/node_pattern/compiler/debug.rb', line 28

def matched?(node_id)
  @visit[node_id]
end

#success(node_id) ⇒ Object


23
24
25
# File 'lib/rubocop/ast/node_pattern/compiler/debug.rb', line 23

def success(node_id)
  @visit[node_id] = true
end