module RuboCop::AST::MethodIdentifierPredicates

def assignment_method?

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

def bang_method?

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

def camel_case_method?

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

def comparison_method?

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

def const_receiver?

Returns:
  • (Boolean) - whether the receiver of this node is a `const` node
def const_receiver?
  receiver&.const_type?
end

def enumerable_method?

Returns:
  • (Boolean) - whether the method is an Enumerable method
def enumerable_method?
  ENUMERABLE_METHODS.include?(method_name)
end

def enumerator_method?

Returns:
  • (Boolean) - whether the method is an enumerator
def enumerator_method?
  ENUMERATOR_METHODS.include?(method_name) ||
    method_name.to_s.start_with?('each_')
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 negation_method?

Returns:
  • (Boolean) - whether this method is a negation method
def negation_method?
  receiver && method_name == :!
end

def nonmutating_array_method?

Returns:
  • (Boolean) - whether the method is a nonmutating Array method
def nonmutating_array_method?
  NONMUTATING_ARRAY_METHODS.include?(method_name)
end

def nonmutating_binary_operator_method?

Returns:
  • (Boolean) - whether the method is a nonmutating binary operator method
def nonmutating_binary_operator_method?
  NONMUTATING_BINARY_OPERATOR_METHODS.include?(method_name)
end

def nonmutating_hash_method?

Returns:
  • (Boolean) - whether the method is a nonmutating Hash method
def nonmutating_hash_method?
  NONMUTATING_HASH_METHODS.include?(method_name)
end

def nonmutating_operator_method?

Returns:
  • (Boolean) - whether the method is a nonmutating operator method
def nonmutating_operator_method?
  NONMUTATING_OPERATOR_METHODS.include?(method_name)
end

def nonmutating_string_method?

Returns:
  • (Boolean) - whether the method is a nonmutating String method
def nonmutating_string_method?
  NONMUTATING_STRING_METHODS.include?(method_name)
end

def nonmutating_unary_operator_method?

Returns:
  • (Boolean) - whether the method is a nonmutating unary operator method
def nonmutating_unary_operator_method?
  NONMUTATING_UNARY_OPERATOR_METHODS.include?(method_name)
end

def operator_method?

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

def predicate_method?

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

def prefix_bang?

Returns:
  • (Boolean) - whether this method is a prefix bang
def prefix_bang?
  negation_method? && loc.selector.is?('!')
end

def prefix_not?

Returns:
  • (Boolean) - whether this method is a prefix not
def prefix_not?
  negation_method? && loc.selector.is?('not')
end

def self_receiver?

Returns:
  • (Boolean) - whether the receiver of this node is `self`
def self_receiver?
  receiver&.self_type?
end