Skip to content

Instantly share code, notes, and snippets.

@davidh-raybeam
Forked from sionide21/regexen.rb
Created July 31, 2012 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidh-raybeam/3218216 to your computer and use it in GitHub Desktop.
Save davidh-raybeam/3218216 to your computer and use it in GitHub Desktop.
Regex game regression tester
class Regexen
def initialize(a={})
a.default_proc = proc { |h,k| [] }
@good = a[:good]
@bad = a[:bad]
end
def good=(r)
@good << r
end
def bad=(r)
@bad << r
end
def to_s
"Regexen.new good: #{@good}, bad: #{@bad}"
end
def check(r)
@good.find {|b| not r.match(b)} or @bad.find {|b| r.match(b) }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment