Sha256: 6f4490bc6f1c0c462aee71f51a177f66b096a4088969f8c823b9b325688e8fd8

Contents?: true

Size: 605 Bytes

Versions: 7

Compression:

Stored size: 605 Bytes

Contents

# frozen_string_literal: true

module Montrose
  module Rule
    class Until
      include Montrose::Rule

      def self.apply_options(opts)
        return false unless opts[:until]

        {until: opts[:until], exclude_end: opts.fetch(:exclude_end, false)}
      end

      def initialize(opts)
        @end_time = opts.fetch(:until)
        @exclude_end = opts.fetch(:exclude_end)
      end

      def include?(time)
        if @exclude_end
          time < @end_time
        else
          time <= @end_time
        end
      end

      def continue?(_time)
        false
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
montrose-0.18.0 lib/montrose/rule/until.rb
montrose-0.17.0 lib/montrose/rule/until.rb
montrose-0.16.0 lib/montrose/rule/until.rb
montrose-0.15.0 lib/montrose/rule/until.rb
montrose-0.14.0 lib/montrose/rule/until.rb
montrose-0.13.0 lib/montrose/rule/until.rb
montrose-0.12.0 lib/montrose/rule/until.rb