Method: When::V::Event::Enumerator::Logic::Enumerator#initialize
- Defined in:
- lib/when_exe/icalendar.rb
#initialize(by_part, list, position, ref, start, dtstart) ⇒ Enumerator
Returns a new instance of Enumerator.
1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 |
# File 'lib/when_exe/icalendar.rb', line 1629 def initialize(by_part, list, position, ref, start, dtstart) @by_part = by_part @ref = if ref When.Resource(ref, '_n:') else method = list[/\A[^-+\d]+/] if dtstart.frame.note.respond_to?(method) dtstart.frame.note else When.Resource(When::V::Event::RegisteredNotes[method], '_n:') end end @start = start @list = list.split(/,/).map {|w| raise ArgumentError, "The #{by_part} rule format error" unless w =~ /\A(([-+]?\d+)\*)?(.+?)([-+]\d+)?\z/ nth, spec, period = $~[2..4] nth = (nth) ? nth.to_i : position period = When::TM::PeriodDuration.new((period||0).to_i, PostFreqIndex[@by_part]) [nth, spec, period] } end |