Module: SleepingKingStudios::Tools::StringTools

Extended by:
StringTools
Included in:
StringTools
Defined in:
lib/sleeping_king_studios/tools/string_tools.rb

Overview

Tools for working with strings.

Instance Method Summary collapse

Instance Method Details

#pluralize(count, single, plural) ⇒ String

Returns the singular or the plural value, depending on the provided item count.

Examples:

"There are four #{StringTools.pluralize 4, 'light', 'lights'}!"
#=> 'There are four lights!'

Parameters:

  • count (Integer)

    The number of items.

  • single (String)

    The singular form of the word or phrase.

  • plural (String)

    The plural form of the word or phrase.

Returns:

  • (String)

    The single form if count == 1; otherwise the plural form.



23
24
25
# File 'lib/sleeping_king_studios/tools/string_tools.rb', line 23

def pluralize count, single, plural
  1 == count ? single : plural
end