Last active
January 3, 2016 16:19
-
-
Save smosher/8488715 to your computer and use it in GitHub Desktop.
Grep role for Sequences.
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
Regex | |
GrepRole := Object clone do( | |
grep := method(x, | |
self split("\n") select( | |
matchesOfRegex(x) map(k, k) size > 0 | |
) map(k, k) | |
) | |
) | |
Sequence appendProto(GrepRole) |
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
// Usage: | |
GrepRole | |
Socket slotSummary asString grep("connect" asRegex caseless) foreach(println) | |
// Nb. grep uses matchesOfRegex which will accept plain strings too. | |
/* Output: | |
Io> Socket slotSummary asString grep("connect" asRegex caseless) foreach(println) | |
asyncConnect = Socket_asyncConnect() | |
connect = method(...) | |
connectTimeout = 60 | |
serverWaitForConnection = method(...) | |
setConnectTimeout = method(...) | |
syncConnect = method(...) | |
==> syncConnect = method(...) | |
Io> | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment