about summary refs log tree commit diff stats
path: root/app/helpers/votes_helper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/helpers/votes_helper.rb')
-rw-r--r--app/helpers/votes_helper.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/app/helpers/votes_helper.rb b/app/helpers/votes_helper.rb new file mode 100644 index 0000000..169d7bf --- /dev/null +++ b/app/helpers/votes_helper.rb
@@ -0,0 +1,32 @@
1module VotesHelper
2
3 def voters_list(votes, html = false)
4 voters = votes.select {|v| !v.liker_url.nil?}.map do |v|
5 if html
6 tag.strong(link_to v.liker_name, v.liker_url)
7 else
8 "#{v.liker_name} (#{v.liker_url})"
9 end
10 end
11
12 anons = votes.select {|v| v.liker_url.nil?}.size
13 if anons > 0
14 if voters.empty? && anons == 1
15 if html
16 voters << tag.strong("A guest")
17 else
18 voters << "A guest"
19 end
20 else
21 if html
22 voters << tag.strong(pluralize(anons, "guest"))
23 else
24 voters << pluralize(anons, "guest")
25 end
26 end
27 end
28
29 to_sentence(voters)
30 end
31
32end