Sha256: 2cb398d98fbf3a0176475f266dfd7e2664b6808092a56b9ea53633ec59cda2bd

Contents?: true

Size: 566 Bytes

Versions: 5

Compression:

Stored size: 566 Bytes

Contents

module Montrose
  module Rule
    class TimeOfDay
      include Montrose::Rule

      def self.apply_options(opts)
        opts[:at]
      end

      # Initializes rule
      #
      # @param [Array<Time>] times - valid hours of days
      #
      def initialize(times)
        @times = times
      end

      def include?(time)
        times_of_day.include?(parts(time))
      end

      private

      def parts(time)
        [time.hour, time.min]
      end

      def times_of_day
        @times_of_day ||= @times.map { |t| parts(t) }
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
montrose-0.2.2 lib/montrose/rule/time_of_day.rb
montrose-0.2.1 lib/montrose/rule/time_of_day.rb
montrose-0.2.0 lib/montrose/rule/time_of_day.rb
montrose-0.1.1 lib/montrose/rule/time_of_day.rb
montrose-0.1.0 lib/montrose/rule/time_of_day.rb