Object
Returns the value associated with the key. If the has does not contain the key, then the default value is returned.
Optionally, the value can be converted into to an instance of the given class. The supported classes are:
Integer Float Array String Symbol
If the value is nil, then no conversion will be performed.
# File lib/logging/utils.rb, line 25 25: def getopt( *args ) 26: opts = args.last.instance_of?(Hash) ? args.pop : {} 27: key, default = args 28: 29: val = if has_key?(key); self[key] 30: elsif has_key?(key.to_s); self[key.to_s] 31: elsif has_key?(key.to_s.intern); self[key.to_s.intern] 32: else default end 33: 34: return if val.nil? 35: return val unless opts.has_key?(:as) 36: 37: case opts[:as].name.intern 38: when :Integer; Integer(val) 39: when :Float; Float(val) 40: when :Array; Array(val) 41: when :String; String(val) 42: when :Symbol; String(val).intern 43: else val end 44: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.