class Hash
def slice(*keys)
-
(Hash)
-
Parameters:
-
keys
(Array
) -- the keys to match, Array
def slice(*keys) keys.map! { |key| convert_key(key) } if respond_to?(:convert_key, true) keys.each_with_object(self.class.new) { |k, hash| hash[k] = self[k] if key?(k) } end