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
- #process_case(exp) ⇒ Object private
- #process_else(exp) ⇒ Object private
- #process_elsif(exp) ⇒ Object private
- #process_if(exp) ⇒ Object private
- #process_if_mod(exp) ⇒ Object private
- #process_unless(exp) ⇒ Object private
- #process_unless_mod(exp) ⇒ Object private
- #process_when(exp) ⇒ Object private
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.
48 49 50 51 |
# File 'lib/ripper_ruby_parser/sexp_handlers/conditionals.rb', line 48 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.
80 81 82 83 |
# File 'lib/ripper_ruby_parser/sexp_handlers/conditionals.rb', line 80 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.
15 16 17 18 19 20 21 22 |
# File 'lib/ripper_ruby_parser/sexp_handlers/conditionals.rb', line 15 def process_elsif(exp) _, cond, truepart, falsepart = exp.shift 4 s(:if, unwrap_begin(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.
7 8 9 10 11 12 13 |
# File 'lib/ripper_ruby_parser/sexp_handlers/conditionals.rb', line 7 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.
24 25 26 27 28 29 30 |
# File 'lib/ripper_ruby_parser/sexp_handlers/conditionals.rb', line 24 def process_if_mod(exp) _, cond, truepart = exp.shift 3 construct_conditional(handle_condition(cond), process(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.
32 33 34 35 36 37 38 |
# File 'lib/ripper_ruby_parser/sexp_handlers/conditionals.rb', line 32 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.
40 41 42 43 44 45 46 |
# File 'lib/ripper_ruby_parser/sexp_handlers/conditionals.rb', line 40 def process_unless_mod(exp) _, cond, truepart = exp.shift 3 construct_conditional(handle_condition(cond), nil, process(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.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/ripper_ruby_parser/sexp_handlers/conditionals.rb', line 53 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 values = process(values).sexp_body truepart = map_process_list_compact truepart.sexp_body truepart = if truepart.empty? [nil] else unwrap_block(truepart.shift) + truepart end s(s(:when, s(:array, *values), *truepart), *falsepart) end |