From d3b832ef8a58017f1f91237e840c2594a751e589 Mon Sep 17 00:00:00 2001 From: William Morgan Date: Sun, 2 Nov 2008 10:53:29 -0800 Subject: [PATCH] pluralize minute(s) second(s) patch from "Tomas Pospisek ML" --- lib/sup/index.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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 <