Class: Choice
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Choice
- Defined in:
- app/models/choice.rb
Instance Method Summary collapse
Instance Method Details
#votes_percentage(precision = 1) ⇒ Object
7 8 9 10 11 |
# File 'app/models/choice.rb', line 7 def votes_percentage(precision = 1) total_votes = poll.votes.count percentage = total_votes.eql?(0) ? 0 : ((votes.count.to_f/total_votes.to_f)*100) "%01.#{precision}f" % percentage end |