Métodos compartidos entre todas las clases que se pueden votar Ahora: Debate y Propuesta
# File app/models/tools/votable.rb, line 50 def n_against @against ||= self.votes.count('value', :conditions => "value = -1") end
# File app/models/tools/votable.rb, line 46 def n_in_favor @in_favor ||= self.votes.count('value', :conditions => "value = 1") end
# File app/models/tools/votable.rb, line 42 def participation self.n_in_favor + self.n_against end
# File app/models/tools/votable.rb, line 30 def percent_against 100 - percent_in_favor end
# File app/models/tools/votable.rb, line 25 def percent_in_favor return 0 if participation == 0 (self.n_in_favor * 100.00 / participation).round end
# File app/models/tools/votable.rb, line 34 def percent_neutral 50 end
# File app/models/tools/votable.rb, line 38 def percentage [percent_in_favor, percent_against].sort.last end
# File app/models/tools/votable.rb, line 54 def percentage_to_text if self.percent_in_favor == 50 || self.participation == 0 "neutral" elsif self.percent_in_favor > self.percent_against "in_favor" else "against" end end