Class: Hash
Direct Known Subclasses
Instance Method Summary collapse
- #getopt(opt, default = nil) ⇒ Object
-
#hasopt?(opt, default = nil) ⇒ Boolean
(also: #hasopt)
–}}}.
Instance Method Details
#getopt(opt, default = nil) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/alib-0.5.1/stdext.rb', line 57 def getopt opt, default = nil #--{{{ hash = self keys = opt.respond_to?('each') ? opt : [opt] keys.each do |key| return hash[key] if hash.has_key? key key = "#{ key }" return hash[key] if hash.has_key? key key = key.intern return hash[key] if hash.has_key? key end return default #--}}} end |
#hasopt?(opt, default = nil) ⇒ Boolean Also known as: hasopt
–}}}
71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/alib-0.5.1/stdext.rb', line 71 def hasopt? opt, default = nil #--{{{ hash = self keys = opt.respond_to?('each') ? opt : [opt] keys.each do |key| return key if hash.has_key? key key = "#{ key }" return key if hash.has_key? key key = key.intern return key if hash.has_key? key end return default #--}}} end |