Skip to content

Instantly share code, notes, and snippets.

@ahoward
Created April 27, 2011 15:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahoward/944532 to your computer and use it in GitHub Desktop.
Save ahoward/944532 to your computer and use it in GitHub Desktop.
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