Created
April 27, 2011 15:55
-
-
Save ahoward/944532 to your computer and use it in GitHub Desktop.
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
compile = proc{|w| a, b = w[0..0], w[1..-1]; /^\s*#{ a }(?:#{ b })?\s*$/i} | |
MalePatterns = | |
%w( man male boy ). | |
map(&compile) | |
FemalePatterns = | |
%w( woman female girl ). | |
map(&compile) | |
def normalize_gender! | |
gender = | |
case self.gender.to_s | |
when *MalePatterns | |
'm' | |
when *FemalePatterns | |
'f' | |
end | |
self.gender = gender | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment