Class: Ratable::RatingAverage
- Inherits:
-
Object
- Object
- Ratable::RatingAverage
- Includes:
- ActiveModel::Model
- Defined in:
- app/models/ratable/rating_average.rb
Instance Attribute Summary collapse
-
#ratee ⇒ Object
Returns the value of attribute ratee.
-
#rater ⇒ Object
Returns the value of attribute rater.
-
#ratings ⇒ Object
Returns the value of attribute ratings.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ RatingAverage
constructor
A new instance of RatingAverage.
Constructor Details
#initialize(attributes = {}) ⇒ RatingAverage
Returns a new instance of RatingAverage.
7 8 9 10 11 |
# File 'app/models/ratable/rating_average.rb', line 7 def initialize(attributes={}) attributes.reject! { |k| k == :value } attributes.each { |k,v| send("#{k}=", v) } @value = @ratings.average(:value).to_i end |
Instance Attribute Details
#ratee ⇒ Object
Returns the value of attribute ratee.
5 6 7 |
# File 'app/models/ratable/rating_average.rb', line 5 def ratee @ratee end |
#rater ⇒ Object
Returns the value of attribute rater.
5 6 7 |
# File 'app/models/ratable/rating_average.rb', line 5 def rater @rater end |
#ratings ⇒ Object
Returns the value of attribute ratings.
5 6 7 |
# File 'app/models/ratable/rating_average.rb', line 5 def @ratings end |
#value ⇒ Object
Returns the value of attribute value.
5 6 7 |
# File 'app/models/ratable/rating_average.rb', line 5 def value @value end |