Method: Species.marginal_dietary_requirement_fallback
- Defined in:
- lib/earth/pet/species.rb
.marginal_dietary_requirement_fallback ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/earth/pet/species.rb', line 47 def marginal_dietary_requirement_fallback total_diet_size = thoroughly_researched.map(&:weighted_diet_size).sum.to_f total_population = thoroughly_researched.sum(:population) return 0.0 unless total_population > 0.0 average_weight = thoroughly_researched.weighted_average(:weight, :weighted_by => :population) return 0.0 unless average_weight > 0.0 (total_diet_size / total_population) / average_weight end |