class RuboCop::AST::ArgNode

A node extension for `arg`, `optarg`, `restarg`, `kwarg`, `kwoptarg`, `kwrestarg`, `blockarg`, `shadowarg` and `forward_arg` nodes. This will be used in place of a plain node when the builder constructs the AST, making its methods available to all `arg` nodes within RuboCop.

Public Instance Methods

default?() click to toggle source

Checks whether the argument has a default value

@return [Boolean] whether the argument has a default value

# File lib/rubocop/ast/node/arg_node.rb, line 29
def default?
  optarg_type? || kwoptarg_type?
end
default_value() click to toggle source

Returns the default value of the argument, if any.

@return [Node, nil] the default value of the argument

# File lib/rubocop/ast/node/arg_node.rb, line 20
def default_value
  return unless default?

  node_parts[1]
end
name() click to toggle source

Returns the name of an argument.

@return [Symbol, nil] the name of the argument

# File lib/rubocop/ast/node/arg_node.rb, line 13
def name
  node_parts[0]
end