Skip to content

Instantly share code, notes, and snippets.

@jakeboxer
Created March 14, 2013 03:13
Show Gist options
  • Select an option

  • Save jakeboxer/5158541 to your computer and use it in GitHub Desktop.

Select an option

Save jakeboxer/5158541 to your computer and use it in GitHub Desktop.
# Public: Same as Rails' ActionView::Helpers::TextHelper#pluralize, but
# doesn't include the number in the result.
#
# Example:
# pluralize(2, 'commit') # 2 commits
# pluralize_without_number(2, 'commit') # commits
#
# count - Number to use to determine whether or not to pluralize
# singular - How the word should look when singular
# plural - How the word should look when plural. If nothing is supplied, the
# the Inflector will be used to determine the plural form.
#
# Returns a string.
def pluralize_without_number(count, singular, plural = nil)
pluralize(count, singular, plural).split[1..-1].join(' ')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment