Class: AddressBook::Gmail
Constant Summary collapse
- ADDRESS_BOOK_URL =
"http://www.google.com/m8/feeds/contacts/default/full/?max-results=1000"
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(login, password) ⇒ Gmail
constructor
A new instance of Gmail.
Methods inherited from Base
Constructor Details
#initialize(login, password) ⇒ Gmail
Returns a new instance of Gmail.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/address_book/gmail.rb', line 9 def initialize(login, password) client = GData::Client::Contacts.new client.clientlogin login, password self.contacts = Nokogiri::XML.parse(client.get(ADDRESS_BOOK_URL).body).css("entry").map do |e| name = (e > "title").first.content email = e.at_xpath("gd:email")[:address] [name, email] end rescue GData::Client::AuthorizationError raise AuthenticationError, "Username or password are incorrect" end |