Class: Candidate
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Candidate
- Defined in:
- app/models/candidate.rb
Instance Method Summary collapse
Instance Method Details
#number_of_voters ⇒ Object
18 19 20 |
# File 'app/models/candidate.rb', line 18 def number_of_voters candidate_votes.count end |
#number_of_votes ⇒ Object
14 15 16 |
# File 'app/models/candidate.rb', line 14 def number_of_votes candidate_votes.where(:voted => true).count end |
#percentage ⇒ Object
9 10 11 12 |
# File 'app/models/candidate.rb', line 9 def percentage return 0 if number_of_votes.zero? 100 * number_of_votes / number_of_voters end |