Class: Streamer::Functors::Sum

Inherits:
Functor
  • Object
show all
Defined in:
lib/streamer/functors/sum.rb

Overview

Sum sums the list using the property provided

Instance Attribute Summary

Attributes inherited from Functor

#options, #payload

Instance Method Summary collapse

Methods inherited from Functor

#class_name, #initialize, #type_name

Constructor Details

This class inherits a constructor from Streamer::Functors::Functor

Instance Method Details

#callObject



5
6
7
8
9
# File 'lib/streamer/functors/sum.rb', line 5

def call
  list.inject(0.0) do |total, item|
    total + item[options.fetch(:property)]
  end
end