Rails has a nice function, ordinalize, which converts an integer to a friendly string representation. Namely 1 becomes 1st, 2 becomes 2nd, and so on. My question is how might one implement the inverse feature?
To be more general I'd like to handle both of the following cases:
>> s = "First"
>> s.integerize
=> 1
>> s = 1st
>> s.integerize
=> 1
I am looking for an smart way to do this as opposed to a giant lookup table or just hacking off the last two characters. Any ideas would be appreciated.