Sha256: 7c53b3195ec43f9cd1a3b00f13182035c790cf14110e6376a36c73e0aa1ab152
Contents?: true
Size: 494 Bytes
Versions: 8
Compression:
Stored size: 494 Bytes
Contents
class Hash # Return a hash that includes everything but the given keys. def except(*keys) dup.except!(*keys) end # Replaces the hash without the given keys. def except!(*keys) keys.each { |key| delete(key) } self end # Return a hash that includes only the given keys. 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 has_key?(k) } end end
Version data entries
8 entries across 8 versions & 1 rubygems