123456789_123456789_123456789_123456789_123456789_

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

Relationships & Source Files
Namespace Children
Classes:
Inherits: Object
Defined in: lib/rubocop/ast/node_pattern/compiler/debug.rb

Constant Summary

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

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

[ GitHub ]

  
# 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

#compiler (readonly)

[ GitHub ]

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

attr_reader :pattern, :compiler, :node_pattern

#node_pattern (readonly)

[ GitHub ]

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

attr_reader :pattern, :compiler, :node_pattern

#pattern (readonly)

[ GitHub ]

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

attr_reader :pattern, :compiler, :node_pattern

Instance Method Details

#ruby_ast(ruby) (private)

[ GitHub ]

  
# File 'lib/rubocop/ast/node_pattern/compiler/debug.rb', line 113

def ruby_ast(ruby)
  ProcessedSource.new(ruby, RUBY_VERSION.to_f, '(ruby)').ast
end

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

Returns:

  • (Node)

    the Ruby AST

[ GitHub ]

  
# 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