Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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