Method: ALib::Util#delopt
- Defined in:
- lib/alib-0.5.1/util.rb
#delopt(opt, hash, default = nil) ⇒ Object Also known as: delete_opt, extract_opt, extractopt, xopt
returning the value or, if key is not found, nil or default
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/alib-0.5.1/util.rb', line 176 def delopt opt, hash, default = nil #--{{{ keys = opt.respond_to?('each') ? opt : [opt] keys.each do |key| return hash.delete(key) if hash.has_key? key key = "#{ key }" return hash.delete(key) if hash.has_key? key key = key.intern return hash.delete(key) if hash.has_key? key end return default #--}}} end |