class Hash
Here, we define an additional function in the Hash
class: without
Public Instance Methods
rename_key(old, new)
click to toggle source
Renames the given key
# File lib/ctioga2/utils.rb, line 728 def rename_key(old, new) self[new] = self[old] self.delete(old) end
strip_if_false!(keys)
click to toggle source
Strip the given keys if they evaluate to false
# File lib/ctioga2/utils.rb, line 734 def strip_if_false!(keys) for k in keys if key?(k) and (not self[k]) self.delete(k) end end end
without(*args)
click to toggle source
Returns a copy of the hash without the given keys
# File lib/ctioga2/utils.rb, line 719 def without(*args) ret = self.dup for a in args.flatten ret.delete(a) end return ret end