Class: When::V::Event::Enumerator::Logic::Weekday
- Inherits:
-
Residue
- Object
- When::V::Event::Enumerator::Logic
- Residue
- When::V::Event::Enumerator::Logic::Weekday
- Defined in:
- lib/when_exe/icalendar.rb
Overview
BYWEEKDAY(=BYDAY)を実装
Instance Attribute Summary
Attributes inherited from When::V::Event::Enumerator::Logic
#by_part, #cash, #freq_index, #list
Instance Method Summary collapse
-
#initialize(by_part, list) ⇒ Weekday
constructor
A new instance of Weekday.
Methods inherited from Residue
Methods inherited from When::V::Event::Enumerator::Logic
Constructor Details
#initialize(by_part, list) ⇒ Weekday
Returns a new instance of Weekday.
1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 |
# File 'lib/when_exe/icalendar.rb', line 1577 def initialize(by_part, list) @by_part = by_part @list = list.split(/,/).map {|w| raise ArgumentError, "The BYDAY rule format error" unless w =~ /\A([-+]?\d+)?(MO|TU|WE|TH|FR|SA|SU)([-+]\d+)?\z/ nth, spec, period = $~[1..3] if nth nth = nth.to_i nth = (nth>0) ? nth-1 : nth end residue = When::Coordinates::Residue.day_of_week(spec) >> (nth||0) [nth, residue, When::TM::PeriodDuration.new([0,0,(period||0).to_i])] } end |