Class: Autility::LaCaixa
- Inherits:
-
Object
- Object
- Autility::LaCaixa
- Includes:
- Capybara::DSL, ShowMeTheCookies
- Defined in:
- lib/autility/lacaixa.rb
Overview
Public: A scraper for all the utility invoices in LaCaixa.
Examples
# Download the invoice from September this year and store it in /tmp.
LaCaixa.scrape("user", "password", 9, "/tmp") # Download all invoices from September this year
Class Method Summary collapse
-
.scrape(*args) ⇒ Object
Public: Instantiates a new scraper and fires it to download the utility invoices from LaCaixa.
Instance Method Summary collapse
-
#initialize(user, password, month, folder) ⇒ LaCaixa
constructor
A new instance of LaCaixa.
-
#scrape(index = nil) ⇒ Object
Public: Scrapes the lacaixa website and gets the invoice for the current month, saving it to @folder.
Constructor Details
#initialize(user, password, month, folder) ⇒ LaCaixa
Returns a new instance of LaCaixa.
34 35 36 37 38 39 40 |
# File 'lib/autility/lacaixa.rb', line 34 def initialize(user, password, month, folder) @user = user @password = password @month = month @folder = folder @year = Time.now.year end |
Class Method Details
.scrape(*args) ⇒ Object
Public: Instantiates a new scraper and fires it to download the utility invoices from LaCaixa.
Returns nothing.
30 31 32 |
# File 'lib/autility/lacaixa.rb', line 30 def self.scrape(*args) new(*args).scrape end |
Instance Method Details
#scrape(index = nil) ⇒ Object
Public: Scrapes the lacaixa website and gets the invoice for the current month, saving it to @folder.
Returns the String path of the saved document.
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/autility/lacaixa.rb', line 46 def scrape(index=nil) log_in FileUtils.mkdir_p(@folder) if index filename = "#{@folder}/lacaixa_#{month}_#{@year}__#{index}.pdf" document(index).save(filename) else return document end filename end |