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