forked from thoughtafter/vpim
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ex_ics_api.rb
54 lines (40 loc) · 1.11 KB
/
ex_ics_api.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
require 'vpim/icalendar'
cal = Vpim::Icalendar.create2
cal.add_event do |e|
e.dtstart Date.new(2005, 04, 28)
e.dtend Date.new(2005, 04, 29)
e.summary "Monthly meet-the-CEO day"
e.description <<'---'
Unlike last one, this meeting will change your life because
we are going to discuss your likely demotion if your work isn't
done soon.
---
e.categories [ 'APPOINTMENT' ]
e.categories do |c| c.push 'EDUCATION' end
e.url 'http://www.example.com'
e.sequence 0
e.access_class "PRIVATE"
e.transparency 'OPAQUE'
e.set_text('LOCATION', 'my location')
now = Time.now
e.created now
e.lastmod now
e.organizer do |o|
o.cn = "Example Organizer, Mr."
o.uri = "mailto:[email protected]"
end
attendee = Vpim::Icalendar::Address.create("mailto:[email protected]")
attendee.rsvp = true
e.add_attendee attendee
end
icsfile = cal.encode
puts '--- Encode:'
puts icsfile
puts '--- Decode:'
cal = Vpim::Icalendar.decode(icsfile).first
cal.components do |e|
puts e.summary
puts e.description
puts e.dtstart.to_s
puts e.dtend.to_s
end