class Rufo::Formatter
def visit_ternary_if(node)
def visit_ternary_if(node) # cond ? then : else # # [:ifop, cond, then_body, else_body] _, cond, then_body, else_body = node visit cond consume_space(want_preserve_whitespace: true) consume_op "?" first_space = current_token if space? skip_space if newline? || comment? consume_end_of_line write_indent(next_indent) elsif first_space && @preserve_whitespace write_space first_space[2] else consume_space end visit then_body consume_space(want_preserve_whitespace: true) consume_op ":" first_space = current_token if space? skip_space if newline? || comment? consume_end_of_line write_indent(next_indent) elsif first_space && @preserve_whitespace write_space first_space[2] else consume_space end visit else_body end