Method: RuboCop::Cop::Style::ArrayIntersect#on_send

Defined in:
lib/rubocop/cop/style/array_intersect.rb

#on_send(node) ⇒ Object Also known as: on_csend



142
143
144
145
146
147
148
149
150
151
# File 'lib/rubocop/cop/style/array_intersect.rb', line 142

def on_send(node)
  return if node.block_literal?
  return unless (dot_node, receiver, argument, method_name = bad_intersection?(node))

  dot = dot_node.loc.dot.source
  bang = straight?(method_name) ? '' : '!'
  replacement = "#{bang}#{receiver.source}#{dot}intersect?(#{argument.source})"

  register_offense(node, replacement)
end