Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/bigbench/post_processor/environment.rb

Overview

Adding the sum and average methods to the default array

Instance Method Summary collapse

Instance Method Details

#averageObject



22
23
24
25
# File 'lib/bigbench/post_processor/environment.rb', line 22

def average
  result = sum / size.to_f
  result.nan? ? 0 : result
end

#sumObject



18
19
20
# File 'lib/bigbench/post_processor/environment.rb', line 18

def sum
  reduce(:+).to_f
end