Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/expressive_math/array.rb
Instance Method Summary collapse
Instance Method Details
#average ⇒ Object
11 12 13 |
# File 'lib/expressive_math/array.rb', line 11 def average self.inject { |total, number| total + number }.to_f end |
#total ⇒ Object
2 3 4 5 6 7 8 9 |
# File 'lib/expressive_math/array.rb', line 2 def total if self.length > 0 return self[0] if self.length == 1 self.inject(0) { |number, total| total + number } else 0 end end |