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, #exclude_end, #has_next?, #next, #succ, #with_index, #with_object
Constructor Details
#initialize(parent, range, options) ⇒ Enumerator #initialize(parent, first, direction, options) ⇒ Enumerator
オブジェクトの生成
651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 |
# File 'lib/when_exe/calendarnote.rb', line 651 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 event = .delete(:event) case event when String ; void, @event, @parameter = event.split(/\A([^\d]+)/) else ; @event, @parameter = [parent.event, event] end @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
次のイベントを得る
626 627 628 |
# File 'lib/when_exe/calendarnote.rb', line 626 def _succ @current = (@current==:first) ? @first : event_eval(@current + @delta) end |