Class: GoogleCalendar::Calendar
- Inherits:
-
Object
- Object
- GoogleCalendar::Calendar
- Defined in:
- lib/when_exe/googlecalendar.rb
Overview
gcalapi の GoogleCalendar::Calendar クラスへの機能追加
Instance Method Summary collapse
-
#enum_for(conditions = {}) ⇒ Enumerator
(also: #to_enum)
イベントを順に取り出す enumerator.
Instance Method Details
#enum_for(conditions = {}) ⇒ Enumerator Also known as: to_enum
イベントを順に取り出す enumerator
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/when_exe/googlecalendar.rb', line 77 def enum_for(conditions={}) conditions['start-min'] ||= When.now conditions['sortorder'] ||= 'a' conditions['orderby'] = 'starttime' direction = (conditions['sortorder'] == 'd') ? :reverse : :forward first = When.when?(conditions['start-min']) conditions['start-min'] = (When.Calendar('Gregorian') ^ first).to_s if conditions['start-max'] last = When.when?(conditions['start-max']) inner_args = [first...last] conditions['start-max'] = (When.Calendar('Gregorian') ^ last).to_s else inner_args = [first, direction] end confirmed = [] canceled = [] self.events(conditions).each do |event| case event.event_status when 'canceled' ; canceled << event else ; confirmed << event end end outer_args = [first, direction] outer_args << {:exevent => canceled.map {|event| event.to_vevent}} if canceled.length > 0 When::Parts::Enumerator::Integrated.new(self, confirmed.map {|event| event.to_vevent.enum_for(*inner_args) }, *outer_args) end |