Class: RuboCop::AST::NodePattern::Compiler::Debug::Colorizer::Result Private
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Struct
|
|
Instance Chain:
self,
Struct
|
|
Inherits: |
Struct
|
Defined in: | lib/rubocop/ast/node_pattern/compiler/debug.rb |
Overview
Result of a NodePattern run against a particular AST Consider constructor is private
Instance Attribute Summary
-
#colorizer
rw
Internal use only
Result of a NodePattern run against a particular AST Consider constructor is private.
-
#returned
rw
Internal use only
Result of a NodePattern run against a particular AST Consider constructor is private.
-
#ruby_ast
rw
Internal use only
Result of a NodePattern run against a particular AST Consider constructor is private.
-
#trace
rw
Internal use only
Result of a NodePattern run against a particular AST Consider constructor is private.
Instance Method Summary
- #color_map(color_scheme = COLOR_SCHEME) ⇒ Hash Internal use only
- #colorize(color_scheme = COLOR_SCHEME) ⇒ String Internal use only
- #match_map ⇒ Hash Internal use only
- #matched?(node) ⇒ Boolean Internal use only
- #ast private Internal use only
- #color_map_for(node, color) private Internal use only
Instance Attribute Details
#colorizer (rw)
Result of a NodePattern run against a particular AST Consider constructor is private
#returned (rw)
Result of a NodePattern run against a particular AST Consider constructor is private
#ruby_ast (rw)
Result of a NodePattern run against a particular AST Consider constructor is private
#trace (rw)
Result of a NodePattern run against a particular AST Consider constructor is private
Instance Method Details
#ast (private)
[ GitHub ]# File 'lib/rubocop/ast/node_pattern/compiler/debug.rb', line 89
def ast colorizer.node_pattern.ast end
#color_map(color_scheme = COLOR_SCHEME) ⇒ Hash
# File 'lib/rubocop/ast/node_pattern/compiler/debug.rb', line 58
def color_map(color_scheme = COLOR_SCHEME) @color_map ||= match_map .transform_values { |matched| color_scheme.fetch(matched) } .map { |node, color| color_map_for(node, color) } .inject(:merge) .tap { |h| h.default = color_scheme.fetch(:not_visitable) } end
#color_map_for(node, color) (private)
[ GitHub ]# File 'lib/rubocop/ast/node_pattern/compiler/debug.rb', line 83
def color_map_for(node, color) return {} unless (range = node.loc&.expression) range.to_a.to_h { |char| [char, color] } end
#colorize(color_scheme = COLOR_SCHEME) ⇒ String
# File 'lib/rubocop/ast/node_pattern/compiler/debug.rb', line 50
def colorize(color_scheme = COLOR_SCHEME) map = color_map(color_scheme) ast.source_range.source_buffer.source.chars.map.with_index do |char, i| Rainbow(char).color(map[i]) end.join end