Subject: [sup-talk] patch: pluralize minute(s) second(s)

From: [email-masked] (Tomas Pospisek ML)
Date: Thu, 30 Oct 2008 23:38:07 +0000

The patch below makes Sup say "1 second" instead of "1 seconds". Same
for minute(s).
*t

--- lib/sup/index.rb.orig	2008-10-31 00:03:41.000000000 +0100
+++ lib/sup/index.rb	2008-10-31 00:05:24.000000000 +0100
@@ -66,14 +66,19 @@
     @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

     <<EOS

---

From: [email-masked] (William Morgan)
Date: Sun, 02 Nov 2008 10:58:05 -0800

> The patch below makes Sup say "1 second" instead of "1 seconds". Same

Applied, thanks! It will be a little easier for me in the future if you
can use git to generate the patches. But it's not vital. See
http://sup.rubyforge.org/wiki/wiki.pl?Contributing
-- 
William <wmorgan-sup at masanjin.net>