Module: RipperRubyParser::SexpHandlers::Conditionals Private

Defined in:
lib/ripper_ruby_parser/sexp_handlers/conditionals.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Sexp handlers for conditionals

Instance Method Summary collapse

Instance Method Details

#process_case(exp) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



46
47
48
49
# File 'lib/ripper_ruby_parser/sexp_handlers/conditionals.rb', line 46

def process_case(exp)
  _, expr, clauses = exp.shift 3
  s(:case, process(expr), *process(clauses))
end

#process_else(exp) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



75
76
77
78
# File 'lib/ripper_ruby_parser/sexp_handlers/conditionals.rb', line 75

def process_else(exp)
  _, body = exp.shift 2
  process(body)
end

#process_elsif(exp) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



13
14
15
16
17
18
19
20
# File 'lib/ripper_ruby_parser/sexp_handlers/conditionals.rb', line 13

def process_elsif(exp)
  _, cond, truepart, falsepart = exp.shift 4

  s(:if,
    process(cond),
    handle_consequent(truepart),
    handle_consequent(falsepart))
end

#process_if(exp) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



5
6
7
8
9
10
11
# File 'lib/ripper_ruby_parser/sexp_handlers/conditionals.rb', line 5

def process_if(exp)
  _, cond, truepart, falsepart = exp.shift 4

  construct_conditional(handle_condition(cond),
                        handle_consequent(truepart),
                        handle_consequent(falsepart))
end

#process_if_mod(exp) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



22
23
24
25
26
27
28
# File 'lib/ripper_ruby_parser/sexp_handlers/conditionals.rb', line 22

def process_if_mod(exp)
  _, cond, truepart = exp.shift 3

  construct_conditional(handle_condition(cond),
                        handle_operator_argument(truepart),
                        nil)
end

#process_unless(exp) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



30
31
32
33
34
35
36
# File 'lib/ripper_ruby_parser/sexp_handlers/conditionals.rb', line 30

def process_unless(exp)
  _, cond, truepart, falsepart = exp.shift 4

  construct_conditional(handle_condition(cond),
                        handle_consequent(falsepart),
                        handle_consequent(truepart))
end

#process_unless_mod(exp) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



38
39
40
41
42
43
44
# File 'lib/ripper_ruby_parser/sexp_handlers/conditionals.rb', line 38

def process_unless_mod(exp)
  _, cond, truepart = exp.shift 3

  construct_conditional(handle_condition(cond),
                        nil,
                        handle_operator_argument(truepart))
end

#process_when(exp) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/ripper_ruby_parser/sexp_handlers/conditionals.rb', line 51

def process_when(exp)
  _, values, truepart, falsepart = exp.shift 4

  falsepart = process(falsepart)
  falsepart = unwrap_nil falsepart if falsepart

  if falsepart.nil?
    falsepart = [nil]
  elsif falsepart.first.is_a? Symbol
    falsepart = s(falsepart)
  end
  falsepart = [nil] if falsepart.empty?

  values = handle_argument_list values

  truepart = map_process_sexp_body_compact(truepart)
  truepart = [nil] if truepart.empty?

  s(s(:when,
      s(:array, *values),
      *truepart),
    *falsepart)
end