Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/ctioga2/utils.rb
Overview
Here, we define an additional function in the Hash class: without
Instance Method Summary collapse
-
#rename_key(old, new) ⇒ Object
Renames the given key.
-
#without(*args) ⇒ Object
Returns a copy of the hash without the given keys.
Instance Method Details
#rename_key(old, new) ⇒ Object
Renames the given key
238 239 240 241 |
# File 'lib/ctioga2/utils.rb', line 238 def rename_key(old, new) self[new] = self[old] self.delete(old) end |
#without(*args) ⇒ Object
Returns a copy of the hash without the given keys
229 230 231 232 233 234 235 |
# File 'lib/ctioga2/utils.rb', line 229 def without(*args) ret = self.dup for a in args.flatten ret.delete(a) end return ret end |