Sha256: 36d8d860d2e2397f33bda912709b1bf654ae831a7139f42b607d2f37fb9263a2
Contents?: true
Size: 687 Bytes
Versions: 1
Compression:
Stored size: 687 Bytes
Contents
# frozen_string_literal: true # # Copyright (c) 2019-present, Blue Marble Payroll, LLC # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # module Proforma module Compiling # A counter is the actual underlying data structure for aggregation. class Counter attr_reader :count, :sum def initialize @count = 0 @sum = BigDecimal(0) end def add(value) parsed_value = value.to_s.empty? ? 0 : BigDecimal(value.to_s) @count += 1 @sum += parsed_value self end def ave sum / count end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
proforma-1.0.0.pre.alpha | lib/proforma/compiling/counter.rb |