The result of Inflector::pluralize("Agency") is correctly
"Agencies",
but pluralize again and it goes back to the singular ?
Is this as expected ?
Also, I have a need to know if a word is singular or plural, and to
convert it to one or the other regardless of it already being so.
Anyway, I''ve written these which seem to work. Do they already exist
somewhere ?
def is_plural?(astring)
Inflector::singularize(astring)!=astring
end
def is_singular?(astring)
Inflector::singularize(astring)==astring
end
def pluralize2(astring)
is_singular?(astring) ? Inflector::pluralize(astring) : astring
end
def singularize2(astring)
is_plural?(astring) ? Inflector::singularize(astring) : astring
end
magpie
"Just Enough Software Quality":http://jesq.blogspot.com
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---