aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/utils
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew/utils')
-rw-r--r--Library/Homebrew/utils/formatter.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/Library/Homebrew/utils/formatter.rb b/Library/Homebrew/utils/formatter.rb
index 8a9afb9af..88616c6f8 100644
--- a/Library/Homebrew/utils/formatter.rb
+++ b/Library/Homebrew/utils/formatter.rb
@@ -90,4 +90,20 @@ module Formatter
output
end
+
+ def pluralize(count, singular, plural = nil)
+ return "#{count} #{singular}" if count == 1
+
+ *adjectives, noun = singular.split(" ")
+
+ if plural.nil?
+ plural = {
+ "formula" => "formulae",
+ }.fetch(noun, "#{noun}s")
+ end
+
+ words = adjectives << plural
+
+ "#{count} #{words.join(" ")}"
+ end
end