Class: Rufus::Google::Calendar
- Inherits:
-
Object
- Object
- Rufus::Google::Calendar
- Includes:
- CollectionMixin
- Defined in:
- lib/rufus/gcal.rb
Instance Attribute Summary
Attributes included from CollectionMixin
Class Method Summary collapse
-
.get_calendars(options) ⇒ Object
Returns a hash calendar_name => calendar.
Instance Method Summary collapse
-
#events(query = {}) ⇒ Object
Returns all the events in the calendar.
-
#post_quick!(event_text) ⇒ Object
Posts (creates) a QuickAdd event in this calendar.
Methods included from CollectionMixin
Class Method Details
.get_calendars(options) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/rufus/gcal.rb', line 86 def self.get_calendars () [:service] = :cl feed = Rufus::Google.feed_for( 'https://www.google.com/calendar/feeds/default', ) feed.update! # fetch the data over the net feed.entries.inject({}) { |h, e| c = Calendar.new([:auth], e) h[c.name] = c h } end |
Instance Method Details
#events(query = {}) ⇒ Object
Returns all the events in the calendar.
The query hash can be used to ‘query’ those events. It currently accepts :q, :start_min and :start_max as keys.
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/rufus/gcal.rb', line 52 def events (query={}) q = query.inject([]) { |a, (k, v)| a << "#{k.to_s.gsub(/\_/, '-')}=#{v}" }.join("&") q = "?#{q}" if q.length > 0 feed = Rufus::Google.feed_for("#{href}#{q}", @token) feed.update! feed.entries.collect { |e| Event.new(e) } end |
#post_quick!(event_text) ⇒ Object
Posts (creates) a QuickAdd event in this calendar.
code.google.com/apis/calendar/developers_guide_protocol.html#CreatingQuickAdd
72 73 74 75 |
# File 'lib/rufus/gcal.rb', line 72 def post_quick! (event_text) post!(Event.create_quick(event_text)) end |