Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/heartwood/support/array.rb
Instance Method Summary collapse
Instance Method Details
#average(attr = nil) ⇒ Object
2 3 4 5 6 7 8 |
# File 'lib/heartwood/support/array.rb', line 2 def average(attr = nil) return nil if size == 0 unless attr.nil? return collect(&:"#{attr}").reject(&:nil?).sum.to_f / size.to_f end sum.to_f / size.to_f end |