Created
April 5, 2011 00:53
-
-
Save nthj/902807 to your computer and use it in GitHub Desktop.
Ruby string extensions for easily defining questionable methods like "email?"
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 String | |
def questionable | |
questionable? ? to_s : "#{to_s}?" | |
end | |
def questionable! | |
replace questionable | |
end | |
def questionable? | |
self[-1, 1] == '?' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment