Class: GCal::Calendar

Inherits:
Object
  • Object
show all
Defined in:
lib/gcal/calendar.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#access_levelObject

Returns the value of attribute access_level.



3
4
5
# File 'lib/gcal/calendar.rb', line 3

def access_level
  @access_level
end

#author_emailObject

Returns the value of attribute author_email.



3
4
5
# File 'lib/gcal/calendar.rb', line 3

def author_email
  @author_email
end

#author_nameObject

Returns the value of attribute author_name.



3
4
5
# File 'lib/gcal/calendar.rb', line 3

def author_name
  @author_name
end

#colorObject

Returns the value of attribute color.



3
4
5
# File 'lib/gcal/calendar.rb', line 3

def color
  @color
end

#hiddenObject

Returns the value of attribute hidden.



3
4
5
# File 'lib/gcal/calendar.rb', line 3

def hidden
  @hidden
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/gcal/calendar.rb', line 3

def id
  @id
end

Returns the value of attribute link.



3
4
5
# File 'lib/gcal/calendar.rb', line 3

def link
  @link
end

#published_atObject

Returns the value of attribute published_at.



3
4
5
# File 'lib/gcal/calendar.rb', line 3

def published_at
  @published_at
end

#selectedObject

Returns the value of attribute selected.



3
4
5
# File 'lib/gcal/calendar.rb', line 3

def selected
  @selected
end

#timezoneObject

Returns the value of attribute timezone.



3
4
5
# File 'lib/gcal/calendar.rb', line 3

def timezone
  @timezone
end

#titleObject

Returns the value of attribute title.



3
4
5
# File 'lib/gcal/calendar.rb', line 3

def title
  @title
end

#updated_atObject

Returns the value of attribute updated_at.



3
4
5
# File 'lib/gcal/calendar.rb', line 3

def updated_at
  @updated_at
end

Class Method Details

.parse(entry, path) ⇒ Object



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
# File 'lib/gcal/calendar.rb', line 20

def parse(entry, path)
  calendar_home_url = 'http://www.google.com/calendar/feeds'
  parse_time = Time.respond_to?(:parse)
  calendar = self.new
  
  # common info
  calendar.id = entry['id'][0].gsub(calendar_home_url + path, '')
  calendar.title = entry['title'][0]['content']
  calendar.link = entry['link'][0]['href']
  calendar.access_level = entry['accesslevel'][0]['value']
  calendar.color = entry['color'][0]['value']
  calendar.hidden = entry['hidden'][0]['value'] == 'true'
  calendar.selected = entry['selected'][0]['value'] == 'true'

  # time info
  calendar.timezone = entry['timezone'][0]['value']
  calendar.updated_at = parse_time ? Time.parse(entry['updated'][0]) : entry['updated'][0]
  calendar.published_at = parse_time ? Time.parse(entry['published'][0]) : entry['published'][0]

  # author
  author = entry['author'][0]
  calendar.author_name = author['name'] ? author['name'][0] : ''
  calendar.author_email = author['email'] ? author['email'][0] : ''
  calendar
end

Instance Method Details

#hidden?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/gcal/calendar.rb', line 7

def hidden?
  hidden
end

#selected?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/gcal/calendar.rb', line 15

def selected?
  selected
end

#visibleObject



11
12
13
# File 'lib/gcal/calendar.rb', line 11

def visible
  !hidden?
end