From 7454ff48164046d37da97146e44fb01c9b666154 Mon Sep 17 00:00:00 2001 From: Benjamin Kellermann Date: Mon, 22 Dec 2008 23:27:28 +0100 Subject: count Anonymous participants --- poll.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'poll.rb') diff --git a/poll.rb b/poll.rb index 97aabe8..d706804 100644 --- a/poll.rb +++ b/poll.rb @@ -174,7 +174,8 @@ END def add_participant(name, agreed) htmlname = CGI.escapeHTML(name.strip) if htmlname == "" - htmlname = "Anonymous ##{rand(1000)}" + maximum = @data.keys.collect{|e| e.scan(/^Anonymous #(\d*)/).flatten[0]}.compact.collect{|i| i.to_i}.max + htmlname = "Anonymous ##{maximum + 1}" name = htmlname end @data[htmlname] = {"timestamp" => Time.now } -- cgit v1.2.3