class Spaceship::Tunes::AppRatingSummary

Attributes

five_star_rating_count[R]

@return (Integer) total number of five star ratings recevied

four_star_rating_count[R]

@return (Integer) total number of four star ratings recevied

one_star_rating_count[R]

@return (Integer) total number of one star ratings recevied

rating_count[R]

@return (Integer) total number of ratings recevied

review_count[R]

@return (Integer) total number of reviews recevied

three_star_rating_count[R]

@return (Integer) total number of three star ratings recevied

two_star_rating_count[R]

@return (Integer) total number of two star ratings recevied

Public Class Methods

factory(attrs) click to toggle source

Create a new object based on a hash. This is used to create a new object based on the server response.

# File lib/spaceship/tunes/app_ratings.rb, line 91
def factory(attrs)
  obj = self.new(attrs)
  return obj
end

Public Instance Methods

average_rating() click to toggle source

@return (Float) the average rating for this summary (rounded to 2 decimal places)

# File lib/spaceship/tunes/app_ratings.rb, line 98
def average_rating
  ((self.one_star_rating_count +
    (self.two_star_rating_count * 2) +
    (self.three_star_rating_count * 3) +
    (self.four_star_rating_count * 4) +
    (self.five_star_rating_count * 5)) / self.rating_count.to_f).round(2)
end