Sha256: 32b6614d9fdf3ab79558dd965dbe8eeaa87097c1b173373e5a228446871bd2fd

Contents?: true

Size: 499 Bytes

Versions: 4

Compression:

Stored size: 499 Bytes

Contents

module Streamer
  module Functors
    # Average gives the average of a list given a property.
    class Average < Functor
      def call
        Divide.new(
          payload,
          terms: [total, count]
        ).call
      end

      def total
        Sum.new(
          payload,
          list: options.fetch(:list),
          property: options.fetch(:property)
        ).call
      end

      def count
        Count.new(payload, list: options.fetch(:list)).call
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
streamer-0.2.1 lib/streamer/functors/average.rb
streamer-0.2.0 lib/streamer/functors/average.rb
streamer-0.1.1 lib/streamer/functors/average.rb
streamer-0.1.0 lib/streamer/functors/average.rb