diff options
| author | Markus Reiter | 2017-05-29 17:50:13 +0200 |
|---|---|---|
| committer | Markus Reiter | 2017-05-29 17:50:13 +0200 |
| commit | d700a5ba188b0a01fba21401c4432239c29835bc (patch) | |
| tree | 9be4441f5331743b3979f0310f2a3dc05f0e0906 /Library/Homebrew/utils | |
| parent | 481a91a92d869c7363edcc7c114b972680ba1aaa (diff) | |
| download | brew-d700a5ba188b0a01fba21401c4432239c29835bc.tar.bz2 | |
Use `Formatter::pluralize` where possible.
Diffstat (limited to 'Library/Homebrew/utils')
| -rw-r--r-- | Library/Homebrew/utils/formatter.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Library/Homebrew/utils/formatter.rb b/Library/Homebrew/utils/formatter.rb index 099b1c6d3..a29b43c8d 100644 --- a/Library/Homebrew/utils/formatter.rb +++ b/Library/Homebrew/utils/formatter.rb @@ -91,17 +91,17 @@ module Formatter output end - def pluralize(count, singular, plural = nil) - return "#{count} #{singular}" if count == 1 + def pluralize(count, singular, plural = nil, show_count: true) + return (show_count ? "#{count} #{singular}" : singular.to_s) if count == 1 - *adjectives, noun = singular.split(" ") + *adjectives, noun = singular.to_s.split(" ") plural ||= { "formula" => "formulae", }.fetch(noun, "#{noun}s") - words = adjectives << plural + words = adjectives.push(plural).join(" ") - "#{count} #{words.join(" ")}" + show_count ? "#{count} #{words}" : words end end |
