Class: RuboCop::Erb::RubyExtractor::ErbNodeVisitor

Inherits:
Herb::Visitor
  • Object
show all
Defined in:
lib/rubocop/erb/ruby_extractor.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeErbNodeVisitor

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_nodesObject (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_methodsArray<Symbol>

Returns:

  • (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

Returns:

  • (Boolean)


99
100
101
# File 'lib/rubocop/erb/ruby_extractor.rb', line 99

def comment?(node)
  node.tag_opening.value == '<%#'
end

#escape?(node) ⇒ Boolean

Returns:

  • (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