Module: RipperRubyParser::SexpHandlers::Assignment Private
- Defined in:
- lib/ripper_ruby_parser/sexp_handlers/assignment.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 assignments
Instance Method Summary collapse
- #process_assign(exp) ⇒ Object private
- #process_massign(exp) ⇒ Object private
- #process_mlhs(exp) ⇒ Object private
- #process_mlhs_add_post(exp) ⇒ Object private
- #process_mlhs_add_star(exp) ⇒ Object private
- #process_mlhs_paren(exp) ⇒ Object private
- #process_mrhs_add_star(exp) ⇒ Object private
- #process_mrhs_new_from_args(exp) ⇒ Object private
- #process_opassign(exp) ⇒ Object private
Instance Method Details
#process_assign(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 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/ripper_ruby_parser/sexp_handlers/assignment.rb', line 7 def process_assign(exp) _, lvalue, value = exp.shift 3 lvalue = process(lvalue) value = process(value) case value.sexp_type when :mrhs value.sexp_type = :svalue when :args value = s(:svalue, s(:array, *value.sexp_body)) else value = unwrap_begin(value) end with_line_number(lvalue.line, create_regular_assignment_sub_type(lvalue, value)) end |
#process_massign(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.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ripper_ruby_parser/sexp_handlers/assignment.rb', line 26 def process_massign(exp) _, left, right = exp.shift 3 left = process(left).last right = process(right) case right.sexp_type when :args right.sexp_type = :array when :mrhs _, right = right else right = s(:to_ary, unwrap_begin(right)) end s(:masgn, left, right) end |
#process_mlhs(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.
88 89 90 91 92 93 |
# File 'lib/ripper_ruby_parser/sexp_handlers/assignment.rb', line 88 def process_mlhs(exp) _, *rest = shift_all exp items = map_process_list(rest) s(:masgn, s(:array, *create_multiple_assignment_sub_types(items))) end |
#process_mlhs_add_post(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.
70 71 72 73 74 75 76 |
# File 'lib/ripper_ruby_parser/sexp_handlers/assignment.rb', line 70 def process_mlhs_add_post(exp) _, base, rest = exp.shift 3 base = process(base) rest = process(rest) base.last.push(*rest.last.sexp_body) base end |
#process_mlhs_add_star(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.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/ripper_ruby_parser/sexp_handlers/assignment.rb', line 55 def process_mlhs_add_star(exp) _, base, splatarg = exp.shift 3 masgn = process base splat = process(splatarg) splat_item = if splat.nil? s(:splat) else s(:splat, create_valueless_assignment_sub_type(splat)) end masgn.last << splat_item masgn end |
#process_mlhs_paren(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.
78 79 80 81 82 83 84 85 86 |
# File 'lib/ripper_ruby_parser/sexp_handlers/assignment.rb', line 78 def process_mlhs_paren(exp) _, contents = exp.shift 2 if contents.sexp_type == :mlhs_paren s(:masgn, s(:array, process(contents))) else process(contents) end end |
#process_mrhs_add_star(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 |
# File 'lib/ripper_ruby_parser/sexp_handlers/assignment.rb', line 51 def process_mrhs_add_star(exp) generic_add_star exp end |
#process_mrhs_new_from_args(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.
44 45 46 47 48 49 |
# File 'lib/ripper_ruby_parser/sexp_handlers/assignment.rb', line 44 def process_mrhs_new_from_args(exp) _, inner, last = exp.shift 3 process(inner).tap do |result| result.push process(last) if last end end |
#process_opassign(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.
95 96 97 98 99 100 101 102 103 104 |
# File 'lib/ripper_ruby_parser/sexp_handlers/assignment.rb', line 95 def process_opassign(exp) _, lvalue, (_, operator,), value = exp.shift 4 lvalue = process(lvalue) original_value_type = value.sexp_type value = process(value) operator = operator.chop.to_sym create_operator_assignment_sub_type lvalue, value, operator, original_value_type end |