class Rufo::Formatter
def visit_if_or_unless(node, keyword, check_end = true)
def visit_if_or_unless(node, keyword, check_end = true) # if cond # then_body # else # else_body # end # # [:if, cond, then, else] consume_keyword(keyword) consume_space visit node[1] skip_space # Remove "then" if keyword?("then") next_token skip_space end indent_body node[2] if else_body = node[3] # [:else, else_contents] # [:elsif, cond, then, else] write_indent case else_body[0] when :else consume_keyword "else" indent_body else_body[1] when :elsif visit_if_or_unless else_body, "elsif", false else bug "expected else or elsif, not #{else_body[0]}" end end if check_end write_indent consume_keyword "end" end end