class Hash

Extensions to the core Hash class

def slice(*keys)

Returns:
  • (Hash) - hash containing only the keys given.
def slice(*keys)
  h = {}
  keys.each { |k| h[k] = self[k] if key?(k) }
  h
end