Class: Streamer::Functors::Average
- Inherits:
-
Functor
- Object
- Functor
- Streamer::Functors::Average
show all
- 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
#options, #payload
Instance Method Summary
collapse
Methods inherited from Functor
#class_name, #initialize, #type_name
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: options.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: options.fetch(:list),
property: options.fetch(:property)
).call
end
|