Class: Blackcal::WeeksOfMonthRange
- Inherits:
-
Object
- Object
- Blackcal::WeeksOfMonthRange
- Includes:
- Enumerable
- Defined in:
- lib/blackcal/range/weeks_of_month_range.rb
Overview
Week of month range
Instance Attribute Summary collapse
-
#numbers ⇒ Array<Integer>
(also: #to_a)
readonly
Numbers in range.
Instance Method Summary collapse
-
#cover?(timestamp) ⇒ Boolean
Returns true if it covers timestamp.
-
#each(&block) ⇒ Object
Iterate over range.
-
#initialize(numbers) ⇒ WeeksOfMonthRange
constructor
Initialize numbers range.
Constructor Details
#initialize(numbers) ⇒ WeeksOfMonthRange
Initialize numbers range
20 21 22 |
# File 'lib/blackcal/range/weeks_of_month_range.rb', line 20 def initialize(numbers) @numbers = ArrayUtil.flatten(numbers) if numbers end |
Instance Attribute Details
#numbers ⇒ Array<Integer> (readonly) Also known as: to_a
Returns numbers in range.
12 13 14 |
# File 'lib/blackcal/range/weeks_of_month_range.rb', line 12 def numbers @numbers end |
Instance Method Details
#cover?(timestamp) ⇒ Boolean
Returns true if it covers timestamp
26 27 28 29 30 |
# File 'lib/blackcal/range/weeks_of_month_range.rb', line 26 def cover?() return false if numbers.nil? || numbers.empty? numbers.include?(TimeUtil.week_of_month()) end |
#each(&block) ⇒ Object
Iterate over range
37 38 39 |
# File 'lib/blackcal/range/weeks_of_month_range.rb', line 37 def each(&block) to_a.each(&block) end |