Class: Menthol::Provider

Inherits:
Object
  • Object
show all
Defined in:
lib/menthol/provider.rb

Direct Known Subclasses

Bangkokbank, Kasikornbank, Krungsri, Local

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, username, password, accounts) ⇒ Provider

Returns a new instance of Provider.



6
7
8
9
10
11
# File 'lib/menthol/provider.rb', line 6

def initialize(name, username, password, accounts)
  @name     = name
  @username = username
  @password = password
  @accounts = accounts.map { |a| Account.open(self.name, a) }
end

Instance Attribute Details

#accountsObject (readonly)

Returns the value of attribute accounts.



13
14
15
# File 'lib/menthol/provider.rb', line 13

def accounts
  @accounts
end

Instance Method Details

#amountObject



19
20
21
# File 'lib/menthol/provider.rb', line 19

def amount
  @accounts.map(&:amount).reduce(Money.new(0, "THB"), &:+)
end

#nameObject



15
16
17
# File 'lib/menthol/provider.rb', line 15

def name
  @name || self.class.name.split("::").last
end

#sync!Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/menthol/provider.rb', line 23

def sync!
  browser.goto()

  
  synchronize_accounts
  logout

  browser.quit
  @browser = nil
end