Class: AddressBookImporter::Importer
- Inherits:
-
Object
- Object
- AddressBookImporter::Importer
- Defined in:
- lib/address_book_importer.rb
Instance Attribute Summary collapse
-
#agent ⇒ Object
Returns the value of attribute agent.
-
#contacts ⇒ Object
Returns the value of attribute contacts.
Instance Method Summary collapse
- #fetch_contacts(page) ⇒ Object
-
#initialize(login, password) ⇒ Importer
constructor
A new instance of Importer.
- #login(login, pass) ⇒ Object
Constructor Details
#initialize(login, password) ⇒ Importer
Returns a new instance of Importer.
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/address_book_importer.rb', line 16 def initialize(login, password) begin @agent = ::WWW::Mechanize.new {|a| a.log = nil } #@agent.user_agent = "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)" @agent.user_agent = "Mozilla/5.0 (X11; U; Linux i686; en; rv:1.8.1.1) Gecko/20060601 Epiphany/2.16 Firefox/2.0.0.1 (Ubuntu-edgy)" p = login(login, password) @contacts = fetch_contacts(p) rescue Exception => e raise ParseException.new("Error parsing website + " + e.to_s + e.backtrace.inspect) end raise EmptyEmailException if @contacts.empty? end |
Instance Attribute Details
#agent ⇒ Object
Returns the value of attribute agent.
14 15 16 |
# File 'lib/address_book_importer.rb', line 14 def agent @agent end |
#contacts ⇒ Object
Returns the value of attribute contacts.
14 15 16 |
# File 'lib/address_book_importer.rb', line 14 def contacts @contacts end |
Instance Method Details
#fetch_contacts(page) ⇒ Object
32 33 |
# File 'lib/address_book_importer.rb', line 32 def fetch_contacts(page) end |
#login(login, pass) ⇒ Object
29 30 |
# File 'lib/address_book_importer.rb', line 29 def login(login, pass) end |