Created
July 13, 2011 16:49
-
-
Save cmeiklejohn/1080724 to your computer and use it in GitHub Desktop.
Array of regexp matching with include?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
def include_by_regexp_or_string?(str) | |
any? do |o| | |
o.is_a?(Regexp) ? o =~ str : o == str | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment