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
-
(Array
- the arguments of the method invocation or `nil`)
def arguments node_parts[2..-1] end
def assignment_method?
-
(Boolean)
- whether the invoked method is an assignment.
def assignment_method? !comparison_method? && method_name.to_s.end_with?('=') end
def bang_method?
-
(Boolean)
- whether the invoked method is a bang method
def bang_method? method_name.to_s.end_with?('!') end
def camel_case_method?
-
(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)
-
(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?
-
(Boolean)
- whether the involed method is a comparison
def comparison_method? COMPARISON_OPERATORS.include?(method_name) end
def dot?
-
(Boolean)
- whether the method was called with a connecting dot
def dot? loc.dot && loc.dot.is?('.') end
def double_colon?
-
(Boolean)
- whether the method was called with a connecting dot
def double_colon? loc.dot && loc.dot.is?('::') end
def enumerator_method?
-
(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?
-
(Boolean)
- whether the method is an implicit form of `#call`
def implicit_call? method_name == :call && !loc.selector end
def macro?
-
(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)
-
(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
-
(Symbol)
- the name of the invoked method
def method_name node_parts[1] end
def node_parts
-
(Array)
- the different parts of the `send` node
def node_parts to_a end
def operator_method?
-
(Boolean)
- whether the invoked method is an operator
def operator_method? RuboCop::Cop::Util::OPERATOR_METHODS.include?(method_name) end
def predicate_method?
-
(Boolean)
- whether the invoked method is a predicate method
def predicate_method? method_name.to_s.end_with?('?') end
def receiver
-
(Node, nil)
- the receiver of the invoked method or `nil`
def receiver node_parts[0] end
def self_receiver?
-
(Boolean)
- whether the receiver of this method invocation
def self_receiver? receiver && receiver.self_type? end
def setter_method?
-
(Boolean)
- whether the invoked method is a setter
def setter_method? loc.operator end