Class: Contacts::Google::Contact
- Inherits:
-
Base
- Object
- Base
- Contacts::Google::Contact
show all
- Defined in:
- lib/contacts/google.rb
Constant Summary
collapse
- PRIMARY_EMAIL_TAG =
"<gd:email rel='http://schemas.google.com/g/2005#home' primary='true' address='' />"
Constants inherited
from Base
Base::BASE_XML
Instance Attribute Summary collapse
Attributes inherited from Base
#gmail, #xml
Instance Method Summary
collapse
Methods inherited from Base
#[], #[]=, #create!, #delete!, #edit_url, #id, #load_attributes, #name, #name=, #new?, #update!
Constructor Details
#initialize(gmail, xml = nil) ⇒ Contact
Returns a new instance of Contact.
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
|
# File 'lib/contacts/google.rb', line 408
def initialize(gmail, xml = nil)
super(gmail, xml)
if xml.nil?
@xml.at('category')['term'] = "http://schemas.google.com/contact/2008#contact"
@xml.root.children.push *Hpricot.make(PRIMARY_EMAIL_TAG)
end
@groups = []
(@xml / 'gContact:groupMembershipInfo').each do |e|
@groups << e['href']
end
(@xml / 'gContact:groupMembershipInfo').remove
end
|
Instance Attribute Details
#groups ⇒ Object
Returns the value of attribute groups.
404
405
406
|
# File 'lib/contacts/google.rb', line 404
def groups
@groups
end
|
Instance Method Details
#add_group(group) ⇒ Object
443
444
445
446
447
|
# File 'lib/contacts/google.rb', line 443
def add_group(group)
href = get_group_href(group)
return nil if @groups.include?(href)
@groups << href
end
|
#clear_groups! ⇒ Object
439
440
441
|
# File 'lib/contacts/google.rb', line 439
def clear_groups!
@groups = []
end
|
#create_url ⇒ Object
426
427
428
429
|
# File 'lib/contacts/google.rb', line 426
def create_url
'/m8/feeds/contacts/default/full'
PATH['contacts_full']
end
|
#email ⇒ Object
431
432
433
|
# File 'lib/contacts/google.rb', line 431
def email
@xml.at('gd:email')['address']
end
|
#email=(str) ⇒ Object
435
436
437
|
# File 'lib/contacts/google.rb', line 435
def email=(str)
@xml.at('gd:email')['address'] = str
end
|
#remove_group(group) ⇒ Object
449
450
451
452
|
# File 'lib/contacts/google.rb', line 449
def remove_group(group)
href = get_group_href(group)
@groups.delete(href)
end
|