class Hash

def slice(*keys)

Returns:
  • (Hash) -

Parameters:
  • keys (Array, Array) -- the keys to match
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