Class: When::V::Event
- Inherits:
-
Root
- Object
- BasicTypes::Object
- Root
- When::V::Event
- Extended by:
- Parts::Resource::Pool
- Defined in:
- lib/when_exe/icalendar.rb,
lib/when_exe/icalendar.rb,
lib/when_exe/googlecalendar.rb
Overview
Eventを定義する
BEGIN:VEVENT...END:VEVENT のブロックに対応
Direct Known Subclasses
Defined Under Namespace
Classes: Enumerator
Constant Summary collapse
- Properties =
[['dtstamp', 'uid', 'dtstart'], [], ['class', 'created', 'description', 'geo', 'last_modified', 'location', 'organizer', 'priority', 'seq', 'status', 'summary', 'transp', 'url', 'recurid', 'dtend', 'duration'], [], ['rrule', 'attach', 'attendee', 'categories', 'comment', 'contact', 'exdate', 'exevent', 'rstatus', 'related', 'resources', 'rdate']]
- Classes =
[Root, Alarm]
Constants inherited from Root
Root::AwareProperties, Root::DefaultOptional, Root::DefaultUnique
Constants included from Parts::Resource
Parts::Resource::LabelProperty, Parts::Resource::Prefix, Parts::Resource::PrefixIndex, Parts::Resource::PrefixKeys, Parts::Resource::PrefixValues
Class Attribute Summary collapse
-
.default_until ⇒ When::TM::IntervalLength
readonly
最大打ち切り時間.
Instance Attribute Summary collapse
-
#dtend ⇒ When::TM::TemporalPosition, When::Parts::GeometricComplex
readonly
DTEND Property.
-
#dtstart ⇒ When::TM::TemporalPosition, When::Parts::GeometricComplex
readonly
DTSTART Property.
-
#duration ⇒ When::TM::Duration
readonly
DURATION Property.
-
#exdate ⇒ When::Parts::GeometricComplex
readonly
EXDATE Property.
-
#first_occurrence ⇒ String
readonly
DTSTART Property を first occurrence とするか.
-
#rdate ⇒ Array<When::TM::TemporalPosition, When::Parts::GeometricComplex>
readonly
RDATE Property.
-
#rrule ⇒ Hash
readonly
RRULE Property.
Attributes inherited from Root
Attributes included from Parts::Resource
#_pool, #child, #keys, #locale, #namespace
Class Method Summary collapse
-
._setup_(default_until = nil) ⇒ Object
When::V::Event Class のグローバルな設定を行う.
Instance Method Summary collapse
- #_enumerator_list(args) ⇒ Object
-
#dtstop ⇒ When::TM::TemporalPosition, When::Parts::GeometricComplex
最後のイベント.
-
#each(*args, &block) ⇒ Enumerator
順次実行.
-
#label ⇒ String
ユニーク識別名 - UID Property をユニーク識別名とする。.
-
#to_gcalevent(cal) ⇒ GoogleCalendar::Event
(also: #gcalevent)
GoogleCalendar::Event オブジェクトへの変換.
Methods included from Parts::Resource::Pool
[], []=, _pool, _setup_, pool_keys
Methods included from Parts::Resource::Synchronize
Methods inherited from Root
Methods inherited from BasicTypes::Object
Methods included from Parts::Resource
#[], #^, _extract_prefix, _instance, _parse, _path_with_prefix, #enum_for, #hierarchy, #include?, #included?, #iri, #leaf?, #m17n, #map, #next, #parent, #prev, #registered?
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class When::Parts::Resource
Class Attribute Details
.default_until ⇒ When::TM::IntervalLength (readonly)
最大打ち切り時間
497 498 499 |
# File 'lib/when_exe/icalendar.rb', line 497 def default_until @default_until end |
Instance Attribute Details
#dtend ⇒ When::TM::TemporalPosition, When::Parts::GeometricComplex (readonly)
DTEND Property
539 540 541 |
# File 'lib/when_exe/icalendar.rb', line 539 def dtend @dtend end |
#dtstart ⇒ When::TM::TemporalPosition, When::Parts::GeometricComplex (readonly)
DTSTART Property
533 534 535 |
# File 'lib/when_exe/icalendar.rb', line 533 def dtstart @dtstart end |
#duration ⇒ When::TM::Duration (readonly)
DTSTART Property が保持する When::TM::TemporalPosition の分解能で識別できない 時間差はイベント継続中とみなすので、例えば分解能が DAY の場合、DURATION Porperty に When.Duration(‘P1D’)と指定する必要はない。 DTEND Property が指定された場合、DURATION Property に変換して保持する。
DURATION Property
551 552 553 |
# File 'lib/when_exe/icalendar.rb', line 551 def duration @duration end |
#exdate ⇒ When::Parts::GeometricComplex (readonly)
EXDATE Property
557 558 559 |
# File 'lib/when_exe/icalendar.rb', line 557 def exdate @exdate end |
#first_occurrence ⇒ String (readonly)
RFC 5545 では ‘Include’ となっているが、それ以外の振る舞いが可能なように拡張。
DTSTART Property を first occurrence とするか
581 582 583 |
# File 'lib/when_exe/icalendar.rb', line 581 def first_occurrence @first_occurrence end |
#rdate ⇒ Array<When::TM::TemporalPosition, When::Parts::GeometricComplex> (readonly)
RRULE の COUNT が指定されている場合、後で途中の系列を抜き出すような指定をされても よいように、Enumerator 生成時にCOUNT分の計算をして RDATE Property に登録する。 このため、COUNTに大きな値を指定すると、Enumerator 生成に予想外の時間がかかることが ある。
RDATE Property
569 570 571 |
# File 'lib/when_exe/icalendar.rb', line 569 def rdate @rdate end |
#rrule ⇒ Hash (readonly)
iCalendar の RRULE を Hash に展開したものを保持している。 RRULE は、年のサイクルや7日以外の日のサイクルおよび夏時間の切り替えを 扱えるように RFC 5545 から拡張されている。
RRULE Property
527 528 529 |
# File 'lib/when_exe/icalendar.rb', line 527 def rrule @rrule end |
Class Method Details
._setup_(default_until = nil) ⇒ Object
RRULE の条件が成立しない場合に無限ループにおちいることを避けるため 他に指定がなくとも、計算を打ち切るようにしている。その打ち切り時間 (When.now + default_until)を本メソッドで指定している。 default_until の指定がない場合、default_until は 1000年と解釈する。
When::V::Event Class のグローバルな設定を行う
509 510 511 512 513 514 515 |
# File 'lib/when_exe/icalendar.rb', line 509 def _setup_(default_until=nil) @_lock_ = Mutex.new if When.multi_thread @_lock_.lock if @_lock_ @_pool = {} @default_until = default_until @_lock_.unlock if @_lock_ end |
Instance Method Details
#_enumerator_list(args) ⇒ Object
641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 |
# File 'lib/when_exe/icalendar.rb', line 641 def _enumerator_list(args) = args[-1] rdate = @rdate.dup [:exdate] = @exdate.dup if @exdate [:exevent] = @exevent.map {|v| self[v]} if @exevent case (['1st'] || @first_occurrence).capitalize when 'Include' ; rdate.unshift(@duration ? When::Parts::GeometricComplex.new(@dtstart, @duration) : @dtstart) when 'Exclude' ; [:exdate] |= @dtstart end # 配下の Enumerator の初期化 enumerators = [] @rrule.each do |rrule| if @due && !(rrule['UNTIL'] && rrule['UNTIL'] <= @due) rrule = rrule.dup rrule['UNTIL'] = @due end if rrule['COUNT'] Event::Enumerator.new(self, rrule, @dtstart, @duration, @dtstart, ).each {|date| rdate << date } else enumerators << Event::Enumerator.new(self, rrule, @dtstart, @duration, *args) end end enumerators.unshift(When::Parts::Enumerator::Array.new(self, rdate, *args[1..-1])) if (rdate.length > 0) return enumerators end |
#dtstop ⇒ When::TM::TemporalPosition, When::Parts::GeometricComplex
無限に続く可能性がある場合、When::TimeValue::Max(+Infinity)
最後のイベント
598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 |
# File 'lib/when_exe/icalendar.rb', line 598 def dtstop return @dtstop if (@dtstop) @dtstop = @dtstart @rdate.each do |date| @dtstop = date if (date > @dtstop) end @rrule.each do |rrule| unless (rrule['UNTIL']) @dtstop = When::TimeValue::Max break end @dtstop = rrule['UNTIL'] if (rrule['UNTIL'] > @dtstop) end return @dtstop end |
#initialize ⇒ Enumerator #initialize(range, count_limit = nil) ⇒ Enumerator #initialize(first, direction, count_limit) ⇒ Enumerator
block が与えられている場合、yield する。
順次実行
632 633 634 635 636 637 638 |
# File 'lib/when_exe/icalendar.rb', line 632 def each(*args, &block) if args.length > 0 super else super(@dtstart, &block) end end |
#label ⇒ String
ユニーク識別名 - UID Property をユニーク識別名とする。
587 588 589 |
# File 'lib/when_exe/icalendar.rb', line 587 def label @property['uid'].object end |
#to_gcalevent(cal) ⇒ GoogleCalendar::Event Also known as: gcalevent
GoogleCalendar::Event オブジェクトへの変換
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/when_exe/googlecalendar.rb', line 120 def to_gcalevent(cal) event = cal.create_event event.title = summary if respond_to?(:summary) event.desc = description if respond_to?(:description) event.where = location if respond_to?(:location) if rrule.size == 0 event.st = dtstart.to_time event.en = dtend.to_time else event.recurrence = (['RRULE:' + property['rrule'][0].object] + ['dtstart', 'dtend'].map {|key| value = property[key].attribute['.'] key.upcase + (value =~ /=/ ? ';' : ':') + value }).join("\n") + "\n" end event end |