Class: Autility::MovistarSpain

Inherits:
Object
  • Object
show all
Includes:
Capybara::DSL, ShowMeTheCookies
Defined in:
lib/autility/movistar_spain.rb

Overview

Public: A scraper for all the utility invoices in MovistarSpain.

Examples

# Download the invoice from September this year and store it in /tmp.
MovistarSpain.scrape("user", "password", 9, "/tmp") # Download all invoices from September this year

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, password, month, folder) ⇒ MovistarSpain

Returns a new instance of MovistarSpain.



31
32
33
34
35
36
37
# File 'lib/autility/movistar_spain.rb', line 31

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 MovistarSpain.

Returns nothing.



27
28
29
# File 'lib/autility/movistar_spain.rb', line 27

def self.scrape(*args)
  new(*args).scrape
end

Instance Method Details

#scrapeObject

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.



43
44
45
46
47
48
49
50
51
# File 'lib/autility/movistar_spain.rb', line 43

def scrape
  setup_capybara
  

  FileUtils.mkdir_p(@folder)
  filename = "#{@folder}/movistar_#{month}_#{@year}.pdf"
  document.save(filename)
  filename
end