class RuboCop::AST::WhenNode

to all ‘when` nodes within RuboCop.
node when the builder constructs the AST, making its methods available
A node extension for `when` nodes. This will be used in place of a plain

def body

Returns:
  • (Node, nil) - the body of the `when` node
def body
  node_parts[-1]
end

def branch_index

Returns:
  • (Integer) - the index of the `when` branch
def branch_index
  parent.when_branches.index(self)
end

def conditions

Returns:
  • (Array) - an array of condition nodes
def conditions
  node_parts[0...-1]
end

def each_condition(&block)

Deprecated:
  • Use `conditions.each`
def each_condition(&block)
  return conditions.to_enum(__method__) unless block
  conditions.each(&block)
  self
end

def then?

Returns:
  • (Boolean) - whether the `when` node has a `then` keyword
def then?
  loc_is?(:begin, 'then')
end