From mboxrd@z Thu Jan 1 00:00:00 1970 From: tpo2@sourcepole.ch (Tomas Pospisek ML) Date: Thu, 30 Oct 2008 23:38:07 +0000 Subject: [sup-talk] patch: pluralize minute(s) second(s) Message-ID: 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 <