Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/core_ext/hash.rb

Instance Method Summary collapse

Instance Method Details

#slice(*keys) ⇒ Object



4
5
6
7
8
9
# File 'lib/core_ext/hash.rb', line 4

def slice(*keys)
  keys = keys.map! { |key| convert_key(key) } if respond_to?(:convert_key)
  hash = self.class.new
  keys.each { |k| hash[k] = self[k] if has_key?(k) }
  hash
end