class RuboCop::AST::CaseNode

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

def branches

Returns:
  • (Array) - an array of the bodies of the when branches
def branches
  bodies = when_branches.map(&:body)
  bodies.push(else_branch) if else?
  bodies
end

def each_when(&block)

Deprecated:
  • Use `when_branches.each`
def each_when(&block)
  return when_branches.to_enum(__method__) unless block_given?
  when_branches.each(&block)
  self
end

def else?

Returns:
  • (Boolean) - whether the `case` statement has an `else` branch
def else?
  loc.else
end

def else_branch

Returns:
  • (nil) - if the case statement does not have an else branch.
  • (Node) - the else branch node of the `case` statement
def else_branch
  node_parts[-1]
end

def keyword

Returns:
  • (String) - the keyword of the `case` statement
def keyword
  'case'
end

def when_branches

Returns:
  • (Array) - an array of `when` nodes
def when_branches
  node_parts[1...-1]
end