| Class | Rufus::Google::Event |
| In: |
lib/rufus/gcal.rb
|
| Parent: | Object |
A google calendar event.
# File lib/rufus/gcal.rb, line 136
136: def self.create (opts)
137:
138: e = Atom::Entry.new
139: e.title = opts[:title]
140: e.updated!
141:
142: if c = opts[:content]
143: e.content = c
144: e.content['type'] = opts[:type] || 'text'
145: end
146:
147: if st = opts[:start_time]
148:
149: st = st.is_a?(DateTime) ? st : DateTime.parse(st)
150: st = st.to_s
151: st = st[0, 10] if opts[:all_day]
152:
153: w = REXML::Element.new('gd:when')
154: w.add_attribute('startTime', st)
155:
156: if et = opts[:end_time]
157:
158: et = et.is_a?(DateTime) ? et : DateTime.parse(et)
159: et = et.to_s
160: et = et[0, 10] if opts[:all_day]
161:
162: w.add_attribute('endTime', et)
163: end
164:
165: e.extensions << w
166: end
167:
168: if rc = opts[:recurrence]
169:
170: r = REXML::Element.new('gd:recurrence')
171: r.text = rc
172:
173: e.extensions << r
174: end
175:
176: e.extensions.attributes['xmlns:gd'] =
177: 'http://schemas.google.com/g/2005'
178: e.extensions.attributes['xmlns:gCal'] =
179: 'http://schemas.google.com/gCal/2005'
180:
181: #p e.to_xml.to_s
182:
183: Event.new(e)
184: end
Creates a QuickAdd event.
code.google.com/apis/calendar/developers_guide_protocol.html#CreatingQuickAdd
# File lib/rufus/gcal.rb, line 191
191: def self.create_quick (text)
192:
193: e = create(
194: :title => 'nada',
195: :type => 'html',
196: :content => text)
197:
198: qa = REXML::Element.new('gCal:quickadd')
199: qa.add_attribute('value', 'true')
200: e.entry.extensions << qa
201:
202: e
203: end
# File lib/rufus/gcal.rb, line 114
114: def end_time
115: evalue('when', 'endTime', :time => true)
116: end
# File lib/rufus/gcal.rb, line 110
110: def start_time
111: evalue('when', 'startTime', :time => true)
112: end
TODO : add method for recurrence
# File lib/rufus/gcal.rb, line 124
124: def to_s
125: {
126: :id => @entry.id,
127: :etag => etag,
128: :title => @entry.title.to_s,
129: :start_time => start_time,
130: :end_time => end_time,
131: :where => where,
132: :author => "#{author.name} #{author.email}"
133: }.inspect
134: end