Class: RuboCop::Erb::RubyExtractor::ErbNodeVisitor
- Inherits:
-
Herb::Visitor
- Object
- Herb::Visitor
- RuboCop::Erb::RubyExtractor::ErbNodeVisitor
- Defined in:
- lib/rubocop/erb/ruby_extractor.rb
Instance Attribute Summary collapse
-
#erb_nodes ⇒ Object
readonly
Returns the value of attribute erb_nodes.
Class Method Summary collapse
Instance Method Summary collapse
- #comment?(node) ⇒ Boolean
- #escape?(node) ⇒ Boolean
-
#initialize ⇒ ErbNodeVisitor
constructor
A new instance of ErbNodeVisitor.
- #record_node(node) ⇒ Object
Constructor Details
#initialize ⇒ ErbNodeVisitor
Returns a new instance of ErbNodeVisitor.
93 94 95 96 |
# File 'lib/rubocop/erb/ruby_extractor.rb', line 93 def initialize @erb_nodes = [] super end |
Instance Attribute Details
#erb_nodes ⇒ Object (readonly)
Returns the value of attribute erb_nodes.
91 92 93 |
# File 'lib/rubocop/erb/ruby_extractor.rb', line 91 def erb_nodes @erb_nodes end |
Class Method Details
.erb_visitor_methods ⇒ Array<Symbol>
87 88 89 |
# File 'lib/rubocop/erb/ruby_extractor.rb', line 87 def self.erb_visitor_methods instance_methods.select { |method_name| method_name.to_s.start_with?('visit_erb_') } end |
Instance Method Details
#comment?(node) ⇒ Boolean
99 100 101 |
# File 'lib/rubocop/erb/ruby_extractor.rb', line 99 def comment?(node) node.tag_opening.value == '<%#' end |
#escape?(node) ⇒ Boolean
104 105 106 |
# File 'lib/rubocop/erb/ruby_extractor.rb', line 104 def escape?(node) node.tag_opening.value == '<%%' end |
#record_node(node) ⇒ Object
117 118 119 120 121 |
# File 'lib/rubocop/erb/ruby_extractor.rb', line 117 def record_node(node) return if comment?(node) || escape?(node) @erb_nodes << node end |