X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=lib%2Fsup%2Findex.rb;h=235a18cb0d7993c306d58f0b0e6168ca4b6ec7c5;hb=acc46fde411f4953b5ed47c76365d5cf0de1c944;hp=12385d31a400aa61985267e508394835bf547e34;hpb=30af1fd364072cabb92763c1ab13849046d6cda7;p=sup 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 <