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