Class: GoogleContacts::Contact

Inherits:
Base
  • Object
show all
Defined in:
lib/google_contacts/contact.rb

Constant Summary collapse

CATEGORY_TERM =
"http://schemas.google.com/contact/2008#contact"

Constants inherited from Base

Base::NAMESPACES

Instance Attribute Summary

Attributes inherited from Base

#xml

Instance Method Summary collapse

Methods inherited from Base

#[], #[]=, #attributes=, #changed?, #delete, #entry_for_batch, feed_for_batch, #href, #insert_xml, #new?, #remove_xml, #save, #updated_at, #url

Constructor Details

#initialize(*args) ⇒ Contact

Returns a new instance of Contact.



7
8
9
10
11
12
13
# File 'lib/google_contacts/contact.rb', line 7

def initialize(*args)
  super
  register_proxy :emails, Proxies::Emails.new(self)
  register_proxy :groups, Proxies::Array.new(self,
    :tag   => "gContact:groupMembershipInfo",
    :attr  => "href")
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class GoogleContacts::Base

Instance Method Details

#emailObject



24
25
26
27
# File 'lib/google_contacts/contact.rb', line 24

def email
  primary = emails.primary
  primary && primary.address
end

#email=(address) ⇒ Object



29
30
31
# File 'lib/google_contacts/contact.rb', line 29

def email=(address)
  emails[address].primary!
end

#inspectObject



33
34
35
# File 'lib/google_contacts/contact.rb', line 33

def inspect
  "\#<GoogleContacts::Contact name=#{name.inspect} email=#{email.inspect}>"
end

#nameObject

Alias “name” to “title”



16
17
18
# File 'lib/google_contacts/contact.rb', line 16

def name
  method_missing(:title)
end

#name=(v) ⇒ Object



20
21
22
# File 'lib/google_contacts/contact.rb', line 20

def name=(v)
  method_missing(:title=, v)
end