Sha256: dcb7f7b7538d25fb4dfdb3af502a4aec75e254fb824454263f8d5e2cc0a5a9d5
Contents?: true
Size: 922 Bytes
Versions: 58
Compression:
Stored size: 922 Bytes
Contents
# frozen_string_literal: true module Decidim # This class executes some measures related to Metrics, and return its results # # - day: Date object # - resource: Object used to make measurements. Object class is dependant within each measure class MetricMeasure def initialize(day, resource) @day = day.try(:to_date) || Time.zone.yesterday raise ArgumentError, "[ERROR] Malformed `day` argument. Format must be `YYYY-MM-DD` and in the past" if @day > Time.zone.today @day ||= Time.zone.yesterday @resource = resource end def valid? @day.present? && @resource.present? end # this method must be overwritten for each Measure class def calculate raise StandardError, "Not implemented" end private def start_time @start_time ||= @day.beginning_of_day end def end_time @end_time ||= @day.end_of_day end end end
Version data entries
58 entries across 58 versions & 1 rubygems