Sha256: 5e8107a04f8d49a06729980aa3be381a836e56cf81071b473069fe690dfd7497

Contents?: true

Size: 355 Bytes

Versions: 4

Compression:

Stored size: 355 Bytes

Contents

module Montrose
  class Frequency
    class Weekly < Frequency
      def include?(time)
        (weeks_since_start(time) % @interval).zero?
      end

      private

      def weeks_since_start(time)
        ((time.beginning_of_week - base_date) / 1.week).round
      end

      def base_date
        @starts.beginning_of_week
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
montrose-0.6.0 lib/montrose/frequency/weekly.rb
montrose-0.5.0 lib/montrose/frequency/weekly.rb
montrose-0.4.3 lib/montrose/frequency/weekly.rb
montrose-0.4.2 lib/montrose/frequency/weekly.rb