From: William Morgan Date: Sun, 2 Nov 2008 18:53:29 +0000 (-0800) Subject: pluralize minute(s) second(s) X-Git-Url: https://git.notmuchmail.org/git?a=commitdiff_plain;h=d3b832ef8a58017f1f91237e840c2594a751e589;p=sup pluralize minute(s) second(s) patch from "Tomas Pospisek ML" --- diff --git a/lib/sup/index.rb b/lib/sup/index.rb index 12385d3..235a18c 100644 --- a/lib/sup/index.rb +++ b/lib/sup/index.rb @@ -66,14 +66,19 @@ class Index @lock_update_thread = nil end + def possibly_pluralize number_of, kind + "#{number_of} #{kind}" + + if number_of == 1 then "" else "s" end + end + def fancy_lock_error_message_for e - secs = Time.now - e.mtime - mins = secs.to_i / 60 + secs = (Time.now - e.mtime).to_i + mins = secs / 60 time = if mins == 0 - "#{secs.to_i} seconds" + possibly_pluralize secs , "second" else - "#{mins} minutes" + possibly_pluralize mins, "minute" end <