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 arguments
-
(Array
-)
def arguments if numblock_type? [] # Numbered parameters have no block arguments. else node_parts[1] end end
def arguments?
-
(Boolean)
- whether this `block` node takes any arguments
def arguments? !arguments.empty? end
def body
-
(Node, nil)
- the body of the `block` node or `nil`
def body node_parts[2] end
def braces?
-
(Boolean)
- whether the `block` literal is enclosed in braces
def braces? loc.end&.is?('}') end
def closing_delimiter
-
(String)
- the closing delimiter for the `block` literal
def closing_delimiter delimiters.last end
def delimiters
-
(Array
- the delimiters for the `block` literal)
def delimiters [loc.begin.source, loc.end.source].freeze end
def keywords?
-
(Boolean)
- whether the `block` literal is enclosed in `do`-`end`
def keywords? loc.end&.is?('end') end
def lambda?
-
(Boolean)
- whether the `block` literal belongs to a lambda
def lambda? send_node.method?(:lambda) end
def method_name
-
(Symbol)
- the name of the dispatched method
def method_name send_node.method_name end
def multiline?
-
(Boolean)
- whether the `block` literal is on a several lines
def multiline? !single_line? end
def opening_delimiter
-
(String)
- the opening delimiter for the `block` literal
def opening_delimiter delimiters.first end
def send_node
-
(SendNode)
- the `send` node associated with the `block` node
def send_node node_parts[0] end
def single_line?
-
(Boolean)
- whether the `block` literal is on a single line
def single_line? loc.begin.line == loc.end.line end
def void_context?
-
(Boolean)
- whether the `block` node body is a void context
def void_context? VOID_CONTEXT_METHODS.include?(method_name) end