Sha256: df8d288024fbf26a6f83c195f4536fd754a87bebb97bdbc647649299833bf497

Contents?: true

Size: 608 Bytes

Versions: 2

Compression:

Stored size: 608 Bytes

Contents

# frozen_string_literal: true

module Blackcal
  # Number range
  class DayRange
    # @return [Array<Symbol>] numbers in range
    attr_reader :numbers

    # Initialize numbers range
    # @param [Array<Integer>, Integer, nil] numbers
    # @example
    #   NumberRange.new(1)
    # @example
    #   NumberRange.new([1, 2])
    def initialize(numbers)
      @numbers = Array(numbers) if numbers
    end

    # Returns true if it covers timestamp
    # @return [Boolean]
    def cover?(timestamp)
      return false if numbers.nil? || numbers.empty?

      numbers.include?(timestamp.day)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
blackcal-0.2.0 lib/blackcal/range/day_range.rb
blackcal-0.1.0 lib/blackcal/day_range.rb