Created
December 28, 2013 10:02
-
-
Save k-tsj/8157928 to your computer and use it in GitHub Desktop.
Object#assert_pattern
This file contains hidden or 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
require 'pattern-match' | |
class Object | |
def assert_pattern(pattern) | |
match(self) do | |
with(Kernel.eval(pattern, Kernel.binding)) { self } | |
end | |
end | |
end | |
[0].assert_pattern('_[Integer]') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment