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:



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

def recurrence
  @recurrence
end

Instance Method Details

#_instance_to_xmlObject



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

alias :_instance_to_xml :instance_to_xml

#event_statusString

イベントのステータス

Returns:

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


61
62
63
# File 'lib/when_exe/googlecalendar.rb', line 61

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

#instance_to_xmlObject



33
34
35
36
# File 'lib/when_exe/googlecalendar.rb', line 33

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:



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/when_exe/googlecalendar.rb', line 42

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