Module: RipperRubyParser::SexpHandlers::Literals Private
- Defined in:
- lib/ripper_ruby_parser/sexp_handlers/literals.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 literals
Instance Method Summary collapse
- #process_array(exp) ⇒ Object private
- #process_assoc_splat(exp) ⇒ Object private
-
#process_at_CHAR(exp) ⇒ Object
private
character literals.
- #process_at_float(exp) ⇒ Object private
- #process_at_imaginary(exp) ⇒ Object private
-
#process_at_int(exp) ⇒ Object
private
number literals.
- #process_at_rational(exp) ⇒ Object private
-
#process_hash(exp) ⇒ Object
private
Handle hash literals sexps.
Instance Method Details
#process_array(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 |
# File 'lib/ripper_ruby_parser/sexp_handlers/literals.rb', line 13 def process_array(exp) _, elems = exp.shift 2 return s(:array) if elems.nil? process(elems).tap { |arr| arr.sexp_type = :array } end |
#process_assoc_splat(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.
37 38 39 40 41 42 43 44 |
# File 'lib/ripper_ruby_parser/sexp_handlers/literals.rb', line 37 def process_assoc_splat(exp) _, param = exp.shift 2 if param s(:kwsplat, process(param)) else s(:kwsplat) end end |
#process_at_CHAR(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.
character literals
8 9 10 11 |
# File 'lib/ripper_ruby_parser/sexp_handlers/literals.rb', line 8 def process_at_CHAR(exp) _, val, pos = exp.shift 3 with_position(pos, s(:str, fix_encoding(unescape(val[1..])))) end |
#process_at_float(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/literals.rb', line 51 def process_at_float(exp) make_literal(exp, &:to_f) end |
#process_at_imaginary(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.
59 60 61 |
# File 'lib/ripper_ruby_parser/sexp_handlers/literals.rb', line 59 def process_at_imaginary(exp) make_literal(exp, &:to_c) end |
#process_at_int(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.
number literals
47 48 49 |
# File 'lib/ripper_ruby_parser/sexp_handlers/literals.rb', line 47 def process_at_int(exp) make_literal(exp) { |val| Integer(val) } end |
#process_at_rational(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 |
# File 'lib/ripper_ruby_parser/sexp_handlers/literals.rb', line 55 def process_at_rational(exp) make_literal(exp, &:to_r) end |
#process_hash(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.
Handle hash literals sexps. These can be either empty, or contain a nested :assoclist_from_args Sexp.
27 28 29 30 31 32 33 |
# File 'lib/ripper_ruby_parser/sexp_handlers/literals.rb', line 27 def process_hash(exp) _, body = exp.shift 2 return s(:hash) unless body _, elems = body s(:hash, *make_hash_items(elems)) end |