Sha256: bbcafeab81d652ee2e4516f5307ffd59e6e6ff8179f97caa9d4853b24cd207cc

Contents?: true

Size: 768 Bytes

Versions: 6

Compression:

Stored size: 768 Bytes

Contents

# frozen_string_literal: true

module Montrose
  module Rule
    class Covering
      include Montrose::Rule

      def self.apply_options(opts)
        opts[:covering].is_a?(Range) && opts[:covering]
      end

      # Initializes rule
      #
      # @param [Range] covering - timestamp range
      #
      def initialize(covering)
        @covering = case covering.first
        when Date
          DateRange.new(covering)
        else
          covering
        end
      end

      def include?(time)
        @covering.include?(time)
      end

      def continue?(time)
        time < @covering.last
      end

      class DateRange < SimpleDelegator
        def include?(time)
          __getobj__.include?(time.to_date)
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

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