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
537 538 539 540 |
# File 'lib/ctioga2/utils.rb', line 537 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
528 529 530 531 532 533 534 |
# File 'lib/ctioga2/utils.rb', line 528 def without(*args) ret = self.dup for a in args.flatten ret.delete(a) end return ret end |