I would write it like so:
`return 0 if ratings.empty?
ratings.reduce(:+) / ratings.count`