commit d3b832ef8a58017f1f91237e840c2594a751e589
parent 5931cdd02b995892592f898784dab192c8ef6895
Author: William Morgan <wmorgan-sup@masanjin.net>
Date: Sun, 2 Nov 2008 10:53:29 -0800
pluralize minute(s) second(s)
patch from "Tomas Pospisek ML"
Diffstat:
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git 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
<<EOS