class RuboCop::AST::NodePattern::Compiler::Debug::Colorizer

@api private

def initialize(pattern, compiler: self.class::Compiler.new)

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

def ruby_ast(ruby)

def ruby_ast(ruby)
  buffer = ::Parser::Source::Buffer.new('(ruby)', source: ruby)
  ruby_parser.parse(buffer)
end

def ruby_parser

def ruby_parser
  require 'parser/current'
  builder = ::RuboCop::AST::Builder.new
  ::Parser::CurrentRuby.new(builder)
end

def test(ruby, trace: self.class::Compiler::Trace.new)

Returns:
  • (Node) - the Ruby AST
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