Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/measures/radiance_measure/measure.rb

Instance Method Summary collapse

Instance Method Details

#averageObject



21
22
23
24
25
26
27
# File 'lib/measures/radiance_measure/measure.rb', line 21

def average
  raise 'Cannot average 0 items' if empty?

  sum = inject(:+)

  (sum / size).to_f
end