From 560495b91aeb83cacb23fe4025fee7c76f2de7c6 Mon Sep 17 00:00:00 2001 From: Benjamin Kellermann Date: Fri, 15 Apr 2011 14:37:33 +0200 Subject: change strings to achieve same length for all types --- poll.rb | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'poll.rb') diff --git a/poll.rb b/poll.rb index 372caf7..5c88c08 100644 --- a/poll.rb +++ b/poll.rb @@ -46,9 +46,9 @@ class String end class Poll attr_reader :head, :name - YESVAL = "ayes" - MAYBEVAL = "bmaybe" - NOVAL = "cno" + YESVAL = "a_yes__" + MAYBEVAL = "b_maybe" + NOVAL = "c_no___" def initialize name,type @name = name @@ -112,17 +112,19 @@ class Poll ret += "\n" ret += userstring(participant,showparticipation) @head.columns.each{|column| - klasse = poll[column] - case klasse + case poll[column] when nil value = UNKNOWN klasse = "undecided" - when YESVAL + when /yes/ # allow anything containing yes (backward compatibility) value = YES - when NOVAL + klasse = YESVAL + when /no/ value = NO - when MAYBEVAL + klasse = NOVAL + when /maybe/ value = MAYBE + klasse = MAYBEVAL end ret += "#{value}\n" } @@ -140,9 +142,9 @@ class Poll yes = 0 undecided = 0 @data.each_value{|participant| - if participant[column] == YESVAL + if participant[column] =~ /yes/ yes += 1 - elsif !participant.has_key?(column) or participant[column] == MAYBEVAL + elsif !participant.has_key?(column) or participant[column] =~ /maybe/ undecided += 1 end } -- cgit v1.2.3