Class: WebInvoice::SaisonCard

Inherits:
Object
  • Object
show all
Defined in:
lib/web_invoice/saison_card.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ SaisonCard

Returns a new instance of SaisonCard.



7
8
9
10
11
12
# File 'lib/web_invoice/saison_card.rb', line 7

def initialize(opts = {})
  @agent = Mechanize.new
  @user_id = opts[:user]
  @user_password = opts[:password]
  @download_to = opts[:download_to] || '.'
end

Class Method Details

.execute(opts) ⇒ Object



13
14
15
16
17
# File 'lib/web_invoice/saison_card.rb', line 13

def self.execute(opts)
  wi = new opts
  wi.
  wi.download
end

Instance Method Details

#download(folder = nil) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/web_invoice/saison_card.rb', line 21

def download(folder = nil)
  
  folder ||= @download_to
  pwd = `pwd`.chomp
  if folder
    Dir.chdir folder
  end
  @agent.page.link_with(text: '利用明細確認').click
  csv_link = @agent.page.link_with(text: 'CSVダウンロード')
  pdf_link = @agent.page.link_with(text: 'Web明細ダウンロード')
  csv_link.click
  @agent.page.save
  pdf_link.click
  @agent.page.save
  if folder
    Dir.chdir pwd
  end
end

#loginObject



18
19
20
# File 'lib/web_invoice/saison_card.rb', line 18

def 
   unless @login
end