Class: GoogleCalendar::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/when_exe/googlecalendar.rb

Overview

gcalapi の GoogleCalendar::Event クラスへの機能追加

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#recurrenceArray<String>

繰り返しイベントの定義

Returns:



21
22
23
# File 'lib/when_exe/googlecalendar.rb', line 21

def recurrence
  @recurrence
end

Instance Method Details

#_instance_to_xmlObject



26
# File 'lib/when_exe/googlecalendar.rb', line 26

alias :_instance_to_xml :instance_to_xml

#event_statusString

イベントのステータス

Returns:

  • (String)
    ‘confirmed’ - 有効
    ‘canceled’ - 無効


57
58
59
# File 'lib/when_exe/googlecalendar.rb', line 57

def event_status
  @xml.root.elements['gd:eventStatus'].attributes['value'][/[^.]+$/]
end

#instance_to_xmlObject



29
30
31
32
# File 'lib/when_exe/googlecalendar.rb', line 29

def instance_to_xml
  _instance_to_xml
  @xml.root.elements[recurrence ? "gd:when" : "gd:recurrence"].remove
end

#to_veventWhen::V::Event Also known as: vevent

When::V::Event オブジェクトへの変換

Returns:



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/when_exe/googlecalendar.rb', line 38

def to_vevent
  options = {'summary'=>@title, 'description'=>@desc, 'location'=>@where}
  if @recurrence
    @recurrence.each_line do |line|
      options[$1.downcase] ||= $2 if line =~ /^(DTSTART|DTEND|RRULE).(.+)$/i
    end
  else
    options.update({'dtstart'=>When.when?(@st), 'dtend'=>When.when?(@en)})
  end
  When::V::Event.new(options)
end