class Blackcal::WeeksOfMonthRange

Week of month range

Attributes

numbers[R]

@return [Array<Integer>] numbers in range

to_a[R]

@return [Array<Integer>] numbers in range

Public Class Methods

new(numbers) click to toggle source

Initialize numbers range @param [Array<Integer>, Integer, nil] numbers @example

WeeksOfMonthRange.new(1)

@example

WeeksOfMonthRange.new([1, 2])
# File lib/blackcal/range/weeks_of_month_range.rb, line 20
def initialize(numbers)
  @numbers = ArrayUtil.flatten(numbers) if numbers
end

Public Instance Methods

cover?(timestamp) click to toggle source

Returns true if it covers timestamp @return [Boolean]

# File lib/blackcal/range/weeks_of_month_range.rb, line 26
def cover?(timestamp)
  return false if numbers.nil? || numbers.empty?

  numbers.include?(TimeUtil.week_of_month(timestamp))
end
each(&block) click to toggle source

Iterate over range @see to_a

# File lib/blackcal/range/weeks_of_month_range.rb, line 37
def each(&block)
  to_a.each(&block)
end