Created
May 3, 2012 02:37
-
-
Save rdammkoehler/2582623 to your computer and use it in GitHub Desktop.
Stuff I'm doing
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
def good_or_bad lines, patterns | |
lines.zip(patterns).all? { |(line, pattern)| | |
not(line.match(pattern).nil?) | |
} | |
end | |
def report lines, patterns | |
if good_or_bad(lines, patterns) | |
puts "all lines match the given patterns in order" | |
else | |
puts "one or more lines do not match the given pattern" | |
end | |
end | |
report [ "line1", "line2", "line3" ], [ "pattern1", "pattern2", "pattern3" ] #=> one or more lines do not match the given pattern | |
report [ "line1", "line2", "line3" ], [ "^line", "2$", "line3" ] #=> all lines match the given patterns in order |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
tx, to Magnus Stahre for the tip on all?