Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/hakoy/ext/hash.rb
Instance Method Summary collapse
Instance Method Details
#except(*keys) ⇒ Object
7 8 9 |
# File 'lib/hakoy/ext/hash.rb', line 7 def except(*keys) dup.except!(*keys) end |
#except!(*keys) ⇒ Object
2 3 4 5 |
# File 'lib/hakoy/ext/hash.rb', line 2 def except!(*keys) keys.each { |key| delete(key) } self end |
#slice(*keys) ⇒ Object
11 12 13 14 15 |
# File 'lib/hakoy/ext/hash.rb', line 11 def slice(*keys) keys.each_with_object(self.class.new) do |k, hash| hash[k] = self[k] if has_key?(k) end end |