class RuboCop::AST::SendNode

to all ‘send` nodes within RuboCop.
node when the builder constructs the AST, making its methods available
A node extension for `send` nodes. This will be used in place of a plain

def arguments

Returns:
  • (Array) - the arguments of the method invocation or `nil`
def arguments
  node_parts[2..-1]
end

def assignment_method?

Returns:
  • (Boolean) - whether the invoked method is an assignment.
def assignment_method?
  !comparison_method? && method_name.to_s.end_with?('=')
end

def bang_method?

Returns:
  • (Boolean) - whether the invoked method is a bang method
def bang_method?
  method_name.to_s.end_with?('!')
end

def camel_case_method?

Returns:
  • (Boolean) - whether the invoked method is a camel case method
def camel_case_method?
  method_name.to_s =~ /\A[A-Z]/
end

def command?(name)

Returns:
  • (Boolean) - whether the method name matches the argument

Parameters:
  • name (Symbol, String) -- the method name to check for
def command?(name)
  !receiver && method?(name)
end

def comparison_method?

Returns:
  • (Boolean) - whether the involed method is a comparison
def comparison_method?
  COMPARISON_OPERATORS.include?(method_name)
end

def dot?

Returns:
  • (Boolean) - whether the method was called with a connecting dot
def dot?
  loc.dot && loc.dot.is?('.')
end

def double_colon?

Returns:
  • (Boolean) - whether the method was called with a connecting dot
def double_colon?
  loc.dot && loc.dot.is?('::')
end

def enumerator_method?

Returns:
  • (Boolean) - whether the invoked method is an enumerator.
def enumerator_method?
  ENUMERATOR_METHODS.include?(method_name) ||
    method_name.to_s.start_with?('each_')
end

def implicit_call?

Returns:
  • (Boolean) - whether the method is an implicit form of `#call`
def implicit_call?
  method_name == :call && !loc.selector
end

def macro?

Returns:
  • (Boolean) - whether the method is a macro method

Other tags:
    Note: - This does not include DSLs that use nested blocks, like RSpec
def macro?
  !receiver && macro_scope?
end

def method?(name)

Returns:
  • (Boolean) - whether the method name matches the argument

Parameters:
  • name (Symbol, String) -- the method name to check for
def method?(name)
  method_name == name.to_sym
end

def method_name

Returns:
  • (Symbol) - the name of the invoked method
def method_name
  node_parts[1]
end

def node_parts

Returns:
  • (Array) - the different parts of the `send` node
def node_parts
  to_a
end

def operator_method?

Returns:
  • (Boolean) - whether the invoked method is an operator
def operator_method?
  RuboCop::Cop::Util::OPERATOR_METHODS.include?(method_name)
end

def predicate_method?

Returns:
  • (Boolean) - whether the invoked method is a predicate method
def predicate_method?
  method_name.to_s.end_with?('?')
end

def receiver

Returns:
  • (Node, nil) - the receiver of the invoked method or `nil`
def receiver
  node_parts[0]
end

def self_receiver?

Returns:
  • (Boolean) - whether the receiver of this method invocation
def self_receiver?
  receiver && receiver.self_type?
end

def setter_method?

Returns:
  • (Boolean) - whether the invoked method is a setter
def setter_method?
  loc.operator
end