Class: Autility::Endesa
- Inherits:
-
Object
- Object
- Autility::Endesa
- Includes:
- Capybara::DSL, ShowMeTheCookies
- Defined in:
- lib/autility/endesa.rb
Overview
Public: A scraper for all the utility invoices i Endesa.
Examples
# Download the invoice from September this year and store it in /tmp.
Endesa.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 Endesa.
Instance Method Summary collapse
-
#initialize(user, password, month, folder) ⇒ Endesa
constructor
A new instance of Endesa.
-
#scrape ⇒ Object
Public: Scrapes the endesa website and gets the invoice for the current month, saving it to @folder.
Constructor Details
#initialize(user, password, month, folder) ⇒ Endesa
Returns a new instance of Endesa.
27 28 29 30 31 32 33 |
# File 'lib/autility/endesa.rb', line 27 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 Endesa.
Returns nothing.
23 24 25 |
# File 'lib/autility/endesa.rb', line 23 def self.scrape(*args) new(*args).scrape end |
Instance Method Details
#scrape ⇒ Object
Public: Scrapes the endesa website and gets the invoice for the current month, saving it to @folder.
Returns the String path of the saved document.
39 40 41 42 43 44 45 46 47 |
# File 'lib/autility/endesa.rb', line 39 def scrape log_in FileUtils.mkdir_p(@folder) filename = "#{@folder}/endesa_#{month}_#{@year}.pdf" document.save(filename) filename end |