module RuboCop::AST::ParameterizedNode

Common functionality for nodes that are parameterized: `send`, `super`, `zsuper`, `def`, `defs`

Public Instance Methods

arguments?() click to toggle source

Checks whether this node has any arguments.

@return [Boolean] whether this node has any arguments

# File lib/rubocop/ast/node/mixin/parameterized_node.rb, line 37
def arguments?
  !arguments.empty?
end
block_argument?() click to toggle source

Whether the last argument of the node is a block pass, i.e. `&block`.

@return [Boolean] whether the last argument of the node is a block pass

# File lib/rubocop/ast/node/mixin/parameterized_node.rb, line 55
def block_argument?
  arguments? &&
    (last_argument.block_pass_type? || last_argument.blockarg_type?)
end
first_argument() click to toggle source

A shorthand for getting the first argument of the node. Equivalent to `arguments.first`.

@return [Node, nil] the first argument of the node,

or `nil` if there are no arguments
# File lib/rubocop/ast/node/mixin/parameterized_node.rb, line 21
def first_argument
  arguments[0]
end
last_argument() click to toggle source

A shorthand for getting the last argument of the node. Equivalent to `arguments.last`.

@return [Node, nil] the last argument of the node,

or `nil` if there are no arguments
# File lib/rubocop/ast/node/mixin/parameterized_node.rb, line 30
def last_argument
  arguments[-1]
end
parenthesized?() click to toggle source

Checks whether this node's arguments are wrapped in parentheses.

@return [Boolean] whether this node's arguments are

wrapped in parentheses
# File lib/rubocop/ast/node/mixin/parameterized_node.rb, line 12
def parenthesized?
  loc.end && loc.end.is?(')')
end
rest_argument?()
Alias for: splat_argument?
splat_argument?() click to toggle source

Checks whether any argument of the node is a splat argument, i.e. `*splat`.

@return [Boolean] whether the node is a splat argument

# File lib/rubocop/ast/node/mixin/parameterized_node.rb, line 45
def splat_argument?
  arguments? &&
    (arguments.any?(&:splat_type?) || arguments.any?(&:restarg_type?))
end
Also aliased as: rest_argument?