Class: Contacts::Base
- Inherits:
-
Object
show all
- Defined in:
- lib/contacts/base.rb
Direct Known Subclasses
Aol, Gmail, Gmx, Hotmail, InboxLt, Mailru, Onelt, Plaxo, Seznam, TonlineDe, WebDe, Yahoo
Constant Summary
collapse
- DETECTED_DOMAINS =
[]
Instance Method Summary
collapse
Constructor Details
#initialize(login, password, options = {}) ⇒ Base
Returns a new instance of Base.
16
17
18
19
20
21
22
23
|
# File 'lib/contacts/base.rb', line 16
def initialize(login, password, options={})
@login = login
@password = password
@captcha_token = options[:captcha_token]
@captcha_response = options[:captcha_response]
@connections = {}
connect
end
|
Instance Method Details
#connect ⇒ Object
25
26
27
28
|
# File 'lib/contacts/base.rb', line 25
def connect
real_connect if !@login.nil? && !@login.empty? && !@password.nil? && !@password.empty?
end
|
#connected? ⇒ Boolean
30
31
32
|
# File 'lib/contacts/base.rb', line 30
def connected?
@cookies && !@cookies.empty?
end
|
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/contacts/base.rb', line 34
def contacts(options = {})
return @contacts if @contacts
if connected?
url = URI.parse(contact_list_url)
http = open_http(url)
resp = http.get("#{url.path}?#{url.query}",
"Cookie" => @cookies
)
if resp.code_type != Net::HTTPOK
raise ConnectionError, self.class.const_get(:PROTOCOL_ERROR)
end
parse(resp.body, options)
end
end
|
#login ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/contacts/base.rb', line 51
def login
@attempt ||= 0
@attempt += 1
if @attempt == 1
@login
else
if @login.include?("@#{domain}")
@login.sub("@#{domain}","")
else
"#{@login}@#{domain}"
end
end
end
|
#password ⇒ Object
66
67
68
|
# File 'lib/contacts/base.rb', line 66
def password
@password
end
|
#skip_gzip? ⇒ Boolean
70
71
72
|
# File 'lib/contacts/base.rb', line 70
def skip_gzip?
false
end
|