Class: TheFox::Timr::Helper::TranslationHelper
- Inherits:
-
Object
- Object
- TheFox::Timr::Helper::TranslationHelper
- Defined in:
- lib/timr/helper/translation_helper.rb
Class Method Summary collapse
-
.pluralize(n, singular, plural = nil) ⇒ Object
Based on the number ‘n` return singular or plural of a given word.
Class Method Details
.pluralize(n, singular, plural = nil) ⇒ Object
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”
“‘
29 30 31 32 33 34 35 36 37 |
# File 'lib/timr/helper/translation_helper.rb', line 29 def pluralize(n, singular, plural=nil) if n == 1 "1 #{singular}" elsif plural "#{n} #{plural}" else "#{n} #{singular}s" end end |