123456789_123456789_123456789_123456789_123456789_

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

Instance Attribute Summary

::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

::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

#argumentsArray<Node> (readonly)

Returns:

  • (Array<Node>)

    arguments, if any

[ GitHub ]

  
# 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.

Returns:

  • (Boolean)

    whether this node has any arguments

[ GitHub ]

  
# File 'lib/rubocop/ast/node/mixin/parameterized_node.rb', line 119

def arguments?
  children.size > first_argument_index
end

Instance Method Details

#first_argumentNode?

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

Returns:

  • (Node, nil)

    the first argument of the node, or nil if there are no arguments

[ GitHub ]

  
# File 'lib/rubocop/ast/node/mixin/parameterized_node.rb', line 103

def first_argument
  children[first_argument_index]
end

#last_argumentNode?

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

Returns:

  • (Node, nil)

    the last argument of the node, or nil if there are no arguments

[ GitHub ]

  
# File 'lib/rubocop/ast/node/mixin/parameterized_node.rb', line 112

def last_argument
  children[-1] if arguments?
end