String.inflections do |inflect|
inflect.irregular 'focus', 'foci'
inflect.irregular 'criterion', 'criteria'
end
'focus'.plural => 'foci' # good
'foci'.singular => 'focus' # good
'focus'.singular => 'focu' # wrong!
'foci'.plural => 'focis' # wrong!
The irregular method of the String::Inflections module needs create
rules to map the singular and plural forms to themselves. Here's the
patch:
def self.irregular(singular, plural)
+ singular(Regexp.new("(#{singular[0,1]})#{singular[1..-1]}$",
"i"), '\1' + singular[1..-1])
plural(Regexp.new("(#{singular[0,1]})#{singular[1..-1]}$", "i"),
'\1' + plural[1..-1])
singular(Regexp.new("(#{plural[0,1]})#{plural[1..-1]}$", "i"),
'\1' + singular[1..-1])
+ plural(Regexp.new("(#{plural[0,1]})#{plural[1..-1]}$", "i"),
'\1' + plural[1..-1])
end
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sequel-talk?hl=en.