Module: RuboCop::AST::ParameterizedNode::RestArguments
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
|
|
Defined in: | lib/rubocop/ast/node/mixin/parameterized_node.rb |
Overview
A specialized ::RuboCop::AST::ParameterizedNode
.
Requires implementing first_argument_index
Implements #arguments as children[first_argument_index..-1]
and optimizes other calls
Constant Summary
-
EMPTY_ARGUMENTS =
# File 'lib/rubocop/ast/node/mixin/parameterized_node.rb', line 86[].freeze
Instance Attribute Summary
- #arguments ⇒ Array<Node> readonly
-
#arguments? ⇒ Boolean
readonly
Checks whether this node has any arguments.
::RuboCop::AST::ParameterizedNode
- Included
#arguments? | Checks whether this node has any arguments. |
#block_argument? | Whether the last argument of the node is a block pass, i.e. |
#parenthesized? | Checks whether this node’s arguments are wrapped in parentheses. |
#rest_argument? | Alias for #splat_argument?. |
#splat_argument? | Checks whether any argument of the node is a splat argument, i.e. |
Instance Method Summary
-
#first_argument ⇒ Node?
A shorthand for getting the first argument of the node.
-
#last_argument ⇒ Node?
A shorthand for getting the last argument of the node.
::RuboCop::AST::ParameterizedNode
- Included
#first_argument | A shorthand for getting the first argument of the node. |
#last_argument | A shorthand for getting the last argument of the node. |
Instance Attribute Details
#arguments ⇒ Array
<Node> (readonly)
# 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? ⇒ Boolean
(readonly)
Checks 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
Instance Method Details
#first_argument ⇒ Node?
A shorthand for getting the first argument of the node.
Equivalent to arguments.first
.
# File 'lib/rubocop/ast/node/mixin/parameterized_node.rb', line 103
def first_argument children[first_argument_index] end
#last_argument ⇒ Node?
A shorthand for getting the last argument of the node.
Equivalent to arguments.last
.
# File 'lib/rubocop/ast/node/mixin/parameterized_node.rb', line 112
def last_argument children[-1] if arguments? end