Module: RipperRubyParser::SexpHandlers::Hashes Private

Defined in:
lib/ripper_ruby_parser/sexp_handlers/hashes.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 hash literals

Instance Method Summary collapse

Instance Method Details

#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.

Examples:

s(:assoc_splat, s(:vcall, s(:@ident, "bar")))


21
22
23
24
# File 'lib/ripper_ruby_parser/sexp_handlers/hashes.rb', line 21

def process_assoc_splat(exp)
  _, param = exp.shift 2
  s(:kwsplat, process(param))
end

#process_bare_assoc_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 implied hashes, such as at the end of argument lists.



27
28
29
30
# File 'lib/ripper_ruby_parser/sexp_handlers/hashes.rb', line 27

def process_bare_assoc_hash(exp)
  _, elems = exp.shift 2
  s(:hash, *make_hash_items(elems))
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.

Examples:

Empty hash

s(:hash, nil)

Hash with contents

s(:hash, s(:assoclist_from_args, ...))


12
13
14
15
16
17
# File 'lib/ripper_ruby_parser/sexp_handlers/hashes.rb', line 12

def process_hash(exp)
  _, body = exp.shift 2
  return s(:hash) unless body
  _, elems = body
  s(:hash, *make_hash_items(elems))
end