Class: Streamer::Functors::Average
- Defined in:
- lib/streamer/functors/average.rb
Overview
Average gives the average of a list given a property.
Instance Attribute Summary
Attributes inherited from Functor
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
#call ⇒ Object
5 6 7 8 9 10 |
# File 'lib/streamer/functors/average.rb', line 5 def call Divide.new( payload, terms: [total, count] ).call end |
#count ⇒ Object
20 21 22 |
# File 'lib/streamer/functors/average.rb', line 20 def count Count.new(payload, list: .fetch(:list)).call end |
#total ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/streamer/functors/average.rb', line 12 def total Sum.new( payload, list: .fetch(:list), property: .fetch(:property) ).call end |