Module: RuboCop::AST::ParameterizedNode::RestArguments
- Includes:
- RuboCop::AST::ParameterizedNode
- Included in:
- IndexNode, IndexasgnNode, LambdaNode, SendNode
- Defined in:
- lib/rubocop/ast/node/mixin/parameterized_node.rb
Overview
A specialized ‘ParameterizedNode`. Requires implementing `first_argument_index` Implements `arguments` as `children` and optimizes other calls
Constant Summary collapse
- EMPTY_ARGUMENTS =
[].freeze
Instance Method Summary collapse
-
#arguments ⇒ Array<Node>
Arguments, if any.
-
#arguments? ⇒ Boolean
Checks whether this node has any arguments.
-
#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.
Methods included from RuboCop::AST::ParameterizedNode
#block_argument?, #parenthesized?, #splat_argument?
Instance Method Details
#arguments ⇒ Array<Node>
Returns arguments, if any.
89 90 91 92 93 94 95 96 |
# 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
Checks whether this node has any arguments.
119 120 121 |
# File 'lib/rubocop/ast/node/mixin/parameterized_node.rb', line 119 def arguments? children.size > first_argument_index end |
#first_argument ⇒ Node?
A shorthand for getting the first argument of the node. Equivalent to ‘arguments.first`.
103 104 105 |
# 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`.
112 113 114 |
# File 'lib/rubocop/ast/node/mixin/parameterized_node.rb', line 112 def last_argument children[-1] if arguments? end |