lib/ripper_parser/sexp_handlers/conditionals.rb
# NOTE: Ripper generates a :case node even for one-line pattern matching,
# which doesn't use the case keyword at all.
Ripper generates a :case node even for one-line pattern matching,
which doesn't use the case keyword at all.
Ripper generates a : case node even for one - line pattern matching which doesn ' t use the case keyword at all .
def process_case(exp)
        _, expr, clauses = exp.shift 3
        expr = process(expr)
        case clauses.sexp_type
        when :in
          first, *rest = process(clauses)
          _, pattern, _, truepart = first
          if truepart.nil?
            if RUBY_VERSION < "3.0.0"
              s(:match_pattern, expr, pattern)
            else
              s(:match_pattern_p, expr, pattern)
            end
          else
            s(:case_match, expr, first, *rest)
          end
        when :right_assign
          _, pattern = process(clauses)
          s(:match_pattern, expr, pattern)
        else
          s(:case, expr, *process(clauses))
        end
      end
def process_case ( exp ) _ , expr , clauses = exp . shift 3 expr = process ( expr ) case clauses . sexp_type when :in first , * rest = process ( clauses ) _ , pattern , _ , truepart = first if truepart . nil? if RUBY_VERSION < "3.0.0" s ( :match_pattern , expr , pattern ) else s ( :match_pattern_p , expr , pattern ) end else s ( :case_match , expr , first , * rest ) end when :right_assign _ , pattern = process ( clauses ) s ( :match_pattern , expr , pattern ) else s ( :case , expr , * process ( clauses ) ) end end
NOTE: Ripper generates a :case node even for one-line pattern matching,
which doesn't use the case keyword at all.
NOTE : Ripper generates a : case node even for one - line pattern matching which doesn ' t use the case keyword at all .
exp