module RuboCop::AST::MethodIdentifierPredicates
def assignment_method?
-
(Boolean)
- whether the method is an assignment
def assignment_method? !comparison_method? && method_name.to_s.end_with?('=') end
def bang_method?
-
(Boolean)
- whether the method is a bang method
def bang_method? method_name.to_s.end_with?('!') end
def camel_case_method?
-
(Boolean)
- whether the method is a camel case method
def camel_case_method? method_name.to_s =~ /\A[A-Z]/ end
def comparison_method?
-
(Boolean)
- whether the method is a comparison
def comparison_method? Node::COMPARISON_OPERATORS.include?(method_name) end
def const_receiver?
-
(Boolean)
- whether the receiver of this node is a `const` node
def const_receiver? receiver && receiver.const_type? end
def enumerator_method?
-
(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)
-
(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?
-
(Boolean)
- whether this method is a negation method
def negation_method? receiver && method_name == :! end
def operator_method?
-
(Boolean)
- whether the method is an operator
def operator_method? OPERATOR_METHODS.include?(method_name) end
def predicate_method?
-
(Boolean)
- whether the method is a predicate method
def predicate_method? method_name.to_s.end_with?('?') end
def prefix_bang?
-
(Boolean)
- whether this method is a prefix bang
def prefix_bang? negation_method? && loc.selector.is?('!') end
def prefix_not?
-
(Boolean)
- whether this method is a prefix not
def prefix_not? negation_method? && loc.selector.is?('not') end
def self_receiver?
-
(Boolean)
- whether the receiver of this node is `self`
def self_receiver? receiver && receiver.self_type? end