Class: Rating
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Rating
- Defined in:
- app/models/rating.rb
Constant Summary collapse
- NB_STARS =
5
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.get_nb_stars ⇒ Object
5 6 7 |
# File 'app/models/rating.rb', line 5 def self.get_nb_stars NB_STARS end |
Instance Method Details
#add_rating(n) ⇒ Object
9 10 11 12 13 14 |
# File 'app/models/rating.rb', line 9 def (n) self.value = value * count + n self.count = count + 1 self.value = value / count save end |
#get_stars ⇒ Object
16 17 18 |
# File 'app/models/rating.rb', line 16 def get_stars (self.value + 0.5).floor end |