Class: StringMap

Inherits:
Object
  • Object
show all
Defined in:
lib/utils/hash_map.rb

Class Method Summary collapse

Class Method Details

.[](hash, *keys) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/utils/hash_map.rb', line 24

def [](hash, *keys)
  return hash if keys.empty? || hash.nil?
  key = keys.shift
  if hash.is_a?(Array)
    map = hash.map { |i| [i, key] }
  else
    map = hash[key]
  end
  [map, *keys]
rescue NoMethodError => _
  nil
end