Module: Downsampler::EnumerableExt
- Defined in:
- lib/downsampler/enumerable_extensions.rb
Instance Method Summary collapse
Instance Method Details
#mean(&block) ⇒ Object
10 11 12 |
# File 'lib/downsampler/enumerable_extensions.rb', line 10 def mean &block sum(&block) / size end |
#sum(&block) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/downsampler/enumerable_extensions.rb', line 3 def sum &block inject(0.0) do |result, el| el = yield(el) if block_given? result + el.to_f end end |