Sha256: 53c466270e8daa2c074ad9c611e46f1373c7a43e150136aa12618bb34859881d
Contents?: true
Size: 701 Bytes
Versions: 16
Compression:
Stored size: 701 Bytes
Contents
# encoding: utf-8 # author: Dominik Richter # author: Christoph Hartmann class HashMap class << self 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 end end class StringMap class << self 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 end end
Version data entries
16 entries across 16 versions & 1 rubygems