Class: AddressBook::Rambler

Inherits:
Base
  • Object
show all
Defined in:
lib/address_book/rambler.rb

Constant Summary collapse

LOGIN_URL =
"http://id.rambler.ru/script/auth.cgi"
ADDRESS_BOOK_URL =
"http://mail.rambler.ru/mail/contacts.cgi"

Instance Attribute Summary

Attributes inherited from Base

#contacts

Instance Method Summary collapse

Methods inherited from Base

#session

Constructor Details

#initialize(login, password) ⇒ Rambler

Returns a new instance of Rambler.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/address_book/rambler.rb', line 8

def initialize(, password)
  response = session.post LOGIN_URL, { :login => , :domain => AddressBook.extract_domain(), :passw => password }

  if response.body.index "errorbox"
    raise AuthenticationError, "Username or password are incorrect"
  end

  response = session.get ADDRESS_BOOK_URL

  self.contacts = Nokogiri::XML.parse(response.body).css("#mailbox-list tbody tr").map do |e|
    name = e.at_css(".mtbox-name").content.strip
    email = e.at_css(".mtbox-email").content.strip
    [name, email]
  end
end