Method: UserInput::TypeSafeHash#each_match
- Defined in:
- lib/user_input/type_safe_hash.rb
#each_match(regex, type, default = nil) ⇒ Object
Enumerates keys that match a regex, passing the match object and the value.
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/user_input/type_safe_hash.rb', line 71 def each_match(regex, type, default = nil) real_hash.each_key() { |key| if (matchinfo = regex.match(key)) value = fetch(key, type, default) if (!value.nil?) yield(matchinfo, value) end end } end |