]> git.cworth.org Git - sup/commitdiff
pluralize minute(s) second(s)
authorWilliam Morgan <wmorgan-sup@masanjin.net>
Sun, 2 Nov 2008 18:53:29 +0000 (10:53 -0800)
committerWilliam Morgan <wmorgan-sup@masanjin.net>
Sun, 2 Nov 2008 18:53:29 +0000 (10:53 -0800)
patch from "Tomas Pospisek ML" <tpo2@sourcepole.ch>

lib/sup/index.rb

index 12385d31a400aa61985267e508394835bf547e34..235a18cb0d7993c306d58f0b0e6168ca4b6ec7c5 100644 (file)
@@ -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
 
     <<EOS