Sha256: 0a1c91b0d48a31a8ac1da8fcb7815cb3d28824467975c64f2acf474d0d7b87fc

Contents?: true

Size: 400 Bytes

Versions: 1

Compression:

Stored size: 400 Bytes

Contents

# frozen_string_literal: true

require "active_support/core_ext"

require "flex_station_data/concerns/service"

module FlexStationData
  class ComputeMean
    include Concerns::Service

    attr_reader :values

    def initialize(values)
      @values = values
    end

    def call
      Float(values.sum) / values.size
    rescue ArgumentError, TypeError, NoMethodError
      nil
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
flex-station-data-1.0.2 lib/flex_station_data/services/compute_mean.rb