Returns the plural form of the word in the string.Usage
Examples
- "post".pluralize #=> "posts"
- "octopus".pluralize #=> "octopi"
- "sheep".pluralize #=> "sheep"
- "words".pluralize #=> "words"
- "the blue mailman".pluralize #=> "the blue mailmen"
- "CamelOctopus".pluralize #=> "CamelOctopi"
I generally use pluralize for creating nice messages for users. The pluralize method can also be helpful for metaprogramming when converting from a class name to a table name.
Test
unit_tests do
test "change singular word to plural word" do
assert_equal "names", "name".pluralize
end
end