Class: When::CalendarTypes::CalendarNote::Enumerator

Inherits:
Parts::Enumerator show all
Defined in:
lib/when_exe/calendartypes.rb

Overview

イベントを取得する Enumerator

Instance Attribute Summary

Attributes inherited from Parts::Enumerator

#count, #count_limit, #current, #direction, #exdate, #first, #index, #last, #object, #options, #parent, #processed

Instance Method Summary collapse

Methods inherited from Parts::Enumerator

_options, #_rewind, #each, #has_next?, #next, #succ, #with_index, #with_object

Constructor Details

#initialize(parent, first, direction, event, count_limit = nil) ⇒ Enumerator

オブジェクトの生成



1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
# File 'lib/when_exe/calendartypes.rb', line 1545

def initialize(parent, first, direction, event, count_limit=nil)
  @parent = parent
  void, @event, @parameter = event.split(/^([^\d]+)/)
  @delta = @parent.send((@event+'_delta').to_sym, @parameter)
  instance_eval %Q{
    def event_eval(date)
      @parent.#{@event}(date, @parameter)
    end
  }
  date = event_eval(first)
  if direction == :reverse
    @delta = -@delta
    date   = event_eval(first + @delta) if first.to_i < date.to_i
  else
    date   = event_eval(first + @delta) if first.to_i > date.to_i
  end
  super(@parent, date, direction, count_limit)
end

Instance Method Details

#_succWhen::TM::TemporalPosition

次のイベントを得る



1531
1532
1533
# File 'lib/when_exe/calendartypes.rb', line 1531

def _succ
  @current = (@current==:first) ? @first : event_eval(@current + @delta)
end