Class: When::CalendarNote::Enumerator
- Inherits:
-
Parts::Enumerator
- Object
- Enumerator
- Parts::Enumerator
- When::CalendarNote::Enumerator
- Defined in:
- lib/when_exe/calendarnote.rb
Overview
イベントを取得する Enumerator
Direct Known Subclasses
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
-
#_succ ⇒ When::TM::TemporalPosition
次のイベントを得る.
-
#initialize(*args) ⇒ Enumerator
constructor
オブジェクトの生成.
Methods inherited from Parts::Enumerator
_options, #_rewind, #each, #has_next?, #next, #succ, #with_index, #with_object
Constructor Details
#initialize(parent, range, options) ⇒ Enumerator #initialize(parent, first, direction, options) ⇒ Enumerator
オブジェクトの生成
623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 |
# File 'lib/when_exe/calendarnote.rb', line 623 def initialize(*args) if args[1].kind_of?(Range) parent, range, = args first = range.first last = range.last direction = first < last ? :forward : :reverse else parent, first, direction, = args end direction = [:direction] if [:direction] @parent = parent void, @event, @parameter = .delete(: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 range ? super(@parent, range.exclude_end? ? date...last : date..last, ) : super(@parent, date, direction, ) end |
Instance Method Details
#_succ ⇒ When::TM::TemporalPosition
次のイベントを得る
598 599 600 |
# File 'lib/when_exe/calendarnote.rb', line 598 def _succ @current = (@current==:first) ? @first : event_eval(@current + @delta) end |