Class: GoogleContactsApi::Group

Inherits:
Result
  • Object
show all
Includes:
Contacts
Defined in:
lib/google_contacts_api/group.rb

Overview

Represents a single group.

Instance Attribute Summary

Attributes inherited from Result

#api

Instance Method Summary collapse

Methods included from Contacts

#get_contacts

Methods inherited from Result

#categories, #content, #deleted?, #etag, #id, #initialize, #inspect, #title, #updated

Constructor Details

This class inherits a constructor from GoogleContactsApi::Result

Instance Method Details

#contacts(params = {}) ⇒ Object

Return the contacts in this group and cache them.



17
18
19
20
# File 'lib/google_contacts_api/group.rb', line 17

def contacts(params = {})
  # contacts in this group
  @contacts ||= get_contacts({"group" => self.id}.merge(params))
end

#contacts!(params = {}) ⇒ Object

Return the contacts in this group, retrieving them again from the server.



23
24
25
26
27
# File 'lib/google_contacts_api/group.rb', line 23

def contacts!(params = {})
  # contacts in this group
  @contacts = nil
  contacts
end


39
40
41
42
# File 'lib/google_contacts_api/group.rb', line 39

def edit_link
  _link = self["link"].find { |l| l.rel == "edit" }
  _link ? _link.href : nil
end

Returns the array of links, as link is an array for Hashie.



30
31
32
# File 'lib/google_contacts_api/group.rb', line 30

def links
  self["link"].map { |l| l.href }
end


34
35
36
37
# File 'lib/google_contacts_api/group.rb', line 34

def self_link
  _link = self["link"].find { |l| l.rel == "self" }
  _link ? _link.href : nil
end

#system_group?Boolean

Return true if this is a system group.

Returns:

  • (Boolean)


7
8
9
# File 'lib/google_contacts_api/group.rb', line 7

def system_group?
  !self["gContact$systemGroup"].nil?
end

#system_group_idObject



11
12
13
14
# File 'lib/google_contacts_api/group.rb', line 11

def system_group_id
  return unless self.system_group?
  self['gContact$systemGroup']['id']
end