class RuboCop::AST::BlockNode

the ‘send` node inside the `block` node.
A `block` node is essentially a method send with a block. Parser nests
to all `send` nodes within RuboCop.
node when the builder constructs the AST, making its methods available
A node extension for `block` nodes. This will be used in place of a plain

def argument_list

Returns:
  • (Array) -
def argument_list
  if numblock_type?
    numbered_arguments
  else
    arguments.argument_list
  end
end

def arguments

Returns:
  • (Array) -
def arguments
  if numblock_type?
    [].freeze # Numbered parameters have no block arguments.
  else
    node_parts[1]
  end
end

def arguments?

Returns:
  • (Boolean) - whether this `block` node takes any arguments
def arguments?
  !arguments.empty?
end

def body

Returns:
  • (Node, nil) - the body of the `block` node or `nil`
def body
  node_parts[2]
end

def braces?

Returns:
  • (Boolean) - whether the `block` literal is enclosed in braces
def braces?
  loc.end.is?('}')
end

def closing_delimiter

Returns:
  • (String) - the closing delimiter for the `block` literal
def closing_delimiter
  delimiters.last
end

def delimiters

Returns:
  • (Array) - the delimiters for the `block` literal
def delimiters
  [loc.begin.source, loc.end.source].freeze
end

def first_argument

Returns:
  • (Node, nil) - the first argument of this block,
def first_argument
  arguments[0]
end

def keywords?

Returns:
  • (Boolean) - whether the `block` literal is enclosed in `do`-`end`
def keywords?
  loc.end.is?('end')
end

def lambda?

Returns:
  • (Boolean) - whether the `block` literal belongs to a lambda
def lambda?
  send_node.method?(:lambda)
end

def last_argument

Returns:
  • (Node, nil) - the last argument of this block,
def last_argument
  arguments[-1]
end

def method_name

Returns:
  • (Symbol) - the name of the dispatched method
def method_name
  send_node.method_name
end

def multiline?

Returns:
  • (Boolean) - whether the `block` literal is on a several lines
def multiline?
  !single_line?
end

def numbered_arguments

Numbered arguments of this `numblock`.
def numbered_arguments
  return [].freeze unless numblock_type?
  max_param = children[1]
  1.upto(max_param).map do |i|
    ArgNode.new(:arg, [:"_#{i}"])
  end.freeze
end

def opening_delimiter

Returns:
  • (String) - the opening delimiter for the `block` literal
def opening_delimiter
  delimiters.first
end

def send_node

Returns:
  • (SendNode) - the `send` node associated with the `block` node
def send_node
  node_parts[0]
end

def single_line?

Returns:
  • (Boolean) - whether the `block` literal is on a single line
def single_line?
  loc.begin.line == loc.end.line
end

def void_context?

Returns:
  • (Boolean) - whether the `block` node body is a void context
def void_context?
  VOID_CONTEXT_METHODS.include?(method_name)
end