This one method stands out as hard to read. This one is probably best to extract out for readability.

```ruby
def movie_rating_slope(years,movie_hash_by_year)
  return 0 if years[0] - years[-1] == 0
  last_year_avg = average_rating_by_year(movie_hash_by_year, years.last)
  first_year_avg = average_rating_by_year(movie_hash_by_year, years.first)
  (last_year_avg - first_year_avg).to_f / (years.last - years.first)
end
```