Class: GCal::Event
- Inherits:
-
Object
- Object
- GCal::Event
- Defined in:
- lib/gcal/event.rb
Constant Summary collapse
- STATUS_REGEXP =
/http\:\/\/schemas\.google\.com\/g\/[0-9]+\#event\./
Instance Attribute Summary collapse
-
#author_email ⇒ Object
Returns the value of attribute author_email.
-
#author_name ⇒ Object
Returns the value of attribute author_name.
-
#end_time ⇒ Object
Returns the value of attribute end_time.
-
#id ⇒ Object
Returns the value of attribute id.
-
#link ⇒ Object
Returns the value of attribute link.
-
#published_at ⇒ Object
Returns the value of attribute published_at.
-
#start_time ⇒ Object
Returns the value of attribute start_time.
-
#status ⇒ Object
Returns the value of attribute status.
-
#title ⇒ Object
Returns the value of attribute title.
-
#updated_at ⇒ Object
Returns the value of attribute updated_at.
-
#where ⇒ Object
Returns the value of attribute where.
-
#who ⇒ Object
Returns the value of attribute who.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#author_email ⇒ Object
Returns the value of attribute author_email.
4 5 6 |
# File 'lib/gcal/event.rb', line 4 def @author_email end |
#author_name ⇒ Object
Returns the value of attribute author_name.
4 5 6 |
# File 'lib/gcal/event.rb', line 4 def @author_name end |
#end_time ⇒ Object
Returns the value of attribute end_time.
4 5 6 |
# File 'lib/gcal/event.rb', line 4 def end_time @end_time end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/gcal/event.rb', line 4 def id @id end |
#link ⇒ Object
Returns the value of attribute link.
4 5 6 |
# File 'lib/gcal/event.rb', line 4 def link @link end |
#published_at ⇒ Object
Returns the value of attribute published_at.
4 5 6 |
# File 'lib/gcal/event.rb', line 4 def published_at @published_at end |
#start_time ⇒ Object
Returns the value of attribute start_time.
4 5 6 |
# File 'lib/gcal/event.rb', line 4 def start_time @start_time end |
#status ⇒ Object
Returns the value of attribute status.
4 5 6 |
# File 'lib/gcal/event.rb', line 4 def status @status end |
#title ⇒ Object
Returns the value of attribute title.
4 5 6 |
# File 'lib/gcal/event.rb', line 4 def title @title end |
#updated_at ⇒ Object
Returns the value of attribute updated_at.
4 5 6 |
# File 'lib/gcal/event.rb', line 4 def updated_at @updated_at end |
#where ⇒ Object
Returns the value of attribute where.
4 5 6 |
# File 'lib/gcal/event.rb', line 4 def where @where end |
#who ⇒ Object
Returns the value of attribute who.
4 5 6 |
# File 'lib/gcal/event.rb', line 4 def who @who end |
Class Method Details
.parse(calendar_id, entry) ⇒ Object
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 |
# File 'lib/gcal/event.rb', line 12 def parse(calendar_id, entry) parse_time = Time.respond_to?(:parse) event = self.new # common info event.id = entry['id'][0].gsub("http://www.google.com/calendar/feeds/#{calendar_id}/private/full/", '') event.title = entry['title'][0]['content'] event.link = entry['link'][0]['href'] event.status = entry['eventStatus'][0]['value'].gsub(Event::STATUS_REGEXP, '') event.where = entry['where'][0]['valueString'] event.who = entry['who'][0]['valueString'] # time info time = entry['when'][0] event.start_time = parse_time ? Time.parse(time['startTime']) : time['startTime'] event.end_time = parse_time ? Time.parse(time['endTime']) : time['endTime'] event.updated_at = parse_time ? Time.parse(entry['updated'][0]) : entry['updated'][0] event.published_at = parse_time ? Time.parse(entry['published'][0]) : entry['published'][0] # author = entry['author'][0] event. = ['name'] ? ['name'][0] : '' event. = ['email'] ? ['email'][0] : '' event end |
.prepare_options(options) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/gcal/event.rb', line 38 def () .symbolize_keys! if Hash.respond_to?(:symbolize_keys!) = {} if [:start_time] ['start-min'] = [:start_time].strftime("%Y-%m-%dT%H:%M:%S") end if [:end_time] ['start-max'] = [:end_time].strftime("%Y-%m-%dT%H:%M:%S") end if [:timezone] ['ctz'] = [:timezone].gsub(' ', '_') end if .size > 0 "?" + .map{|k, v| "#{k}=#{v}" }.join('&') else '' end end |
Instance Method Details
#confirmed? ⇒ Boolean
7 8 9 |
# File 'lib/gcal/event.rb', line 7 def confirmed? status == 'confirmed' end |