Class: RuboCop::AST::NodePattern::Compiler::Debug::Colorizer Private

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

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

API:

  • private

Defined Under Namespace

Classes: Result

Constant Summary collapse

COLOR_SCHEME =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

API:

  • private

{
  not_visitable: :lightseagreen,
  nil => :yellow,
  false => :red,
  true => :green
}.freeze
Compiler =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

API:

  • private

Debug

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pattern, compiler: self.class::Compiler.new) ⇒ Colorizer

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Colorizer.

API:

  • private



98
99
100
101
102
# File 'lib/rubocop/ast/node_pattern/compiler/debug.rb', line 98

def initialize(pattern, compiler: self.class::Compiler.new)
  @pattern = pattern
  @compiler = compiler
  @node_pattern = ::RuboCop::AST::NodePattern.new(pattern, compiler: @compiler)
end

Instance Attribute Details

#compilerObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



96
97
98
# File 'lib/rubocop/ast/node_pattern/compiler/debug.rb', line 96

def compiler
  @compiler
end

#node_patternObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



96
97
98
# File 'lib/rubocop/ast/node_pattern/compiler/debug.rb', line 96

def node_pattern
  @node_pattern
end

#patternObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



96
97
98
# File 'lib/rubocop/ast/node_pattern/compiler/debug.rb', line 96

def pattern
  @pattern
end

Instance Method Details

#test(ruby, trace: self.class::Compiler::Trace.new) ⇒ Node

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the Ruby AST.

Returns:

  • the Ruby AST

API:

  • private



105
106
107
108
109
# File 'lib/rubocop/ast/node_pattern/compiler/debug.rb', line 105

def test(ruby, trace: self.class::Compiler::Trace.new)
  ruby = ruby_ast(ruby) if ruby.is_a?(String)
  returned = @node_pattern.as_lambda.call(ruby, trace: trace)
  self.class::Result.new(self, trace, returned, ruby)
end