module RuboCop::AST::ParameterizedNode::RestArguments
A specialized ‘ParameterizedNode`. Requires implementing `first_argument_index` Implements `arguments` as `children` and optimizes other calls
Constants
- EMPTY_ARGUMENTS
Public Instance Methods
arguments()
click to toggle source
@return [Array<Node>] arguments, if any
# File lib/rubocop/ast/node/mixin/parameterized_node.rb, line 89 def arguments if arguments? children.drop(first_argument_index).freeze else # Skip unneeded Array allocation. EMPTY_ARGUMENTS end end
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 119 def arguments? children.size > first_argument_index 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 103 def first_argument children[first_argument_index] 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 112 def last_argument children[-1] if arguments? end