Code Coverage
 
Lines
Covered
100.00% covered (success)
100.00%
11 / 11
1
module TheFox
1
module Timr
1
module Helper
1
class TranslationHelper
# All methods in this block are static.
1
class << self
# Based on the number `n` return singular or plural of a given word.
#
# For example:
#
# ```
# pluralize(1, 'track', 'tracks')
# => "1 track"
# ```
#
# ```
# pluralize(2, 'track', 'tracks')
# => "2 tracks"
# ```
#
# ```
# pluralize(0, 'track', 'tracks')
# => "0 tracks"
# ```
1
def pluralize(n, singular, plural=nil)
12
if n == 1
5
"1 #{singular}"
7
elsif plural
5
"#{n} #{plural}"
else
2
"#{n} #{singular}s"
end
end
end
end # class TranslationHelper
end # module Helper
end # module Timr
end # module TheFox