On May 20, 10:22 pm, Shawn <[email protected]> wrote:
> 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

This isn't a bug IMO.  Attempting to singularize an already singular
word or pluralize an already plural word will cause problems in many
cases, not just for irregulars.

Jeremy

-- 
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.

Reply via email to