A really cheap way to do this with ActiveSupport would be to do
something like this:
class String
def singular?
self.singularize == self
end
def plural?
self.pluralize == self
end
end
In the console, it looks like this:
>> "things".plural?
=> true
>> "things".singular?
=> false
>> "sheep".plural?
=> true
>> "sheep".singular?
=> true
I don't know if that's the best solution, but it works. :)
--Jeremy
On Fri, May 23, 2008 at 6:07 PM, Mark Dodwell <seo / mkdynamic.co.uk> wrote:
> Does anybody know an easy way to test if a word is singular or plural --
> something a bit smarter than just checking if there is an s on the end!
>
> Thanks,
>
> ~ Mark
> --
> Posted via http://www.ruby-forum.com/.
>
>
--
http://jeremymcanally.com/
http://entp.com
Read my books:
Ruby in Practice (http://manning.com/mcanally/)
My free Ruby e-book (http://humblelittlerubybook.com/)
Or, my blogs:
http://mrneighborly.com
http://rubyinpractice.com