Class: TurkishBanks::Bank

Inherits:
Object
  • Object
show all
Defined in:
lib/turkish_banks/bank.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bank_name) ⇒ Bank

Returns a new instance of Bank.



5
6
7
8
9
10
11
# File 'lib/turkish_banks/bank.rb', line 5

def initialize(bank_name)
  bank_params = TurkishBanks.get_bank_params(bank_name)
  @name    = bank_params['bAd']
  @code    = bank_params['bKd']
  @city    = bank_params['bIlAd']
  @address = bank_params['adr']
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



3
4
5
# File 'lib/turkish_banks/bank.rb', line 3

def address
  @address
end

#cityObject (readonly)

Returns the value of attribute city.



3
4
5
# File 'lib/turkish_banks/bank.rb', line 3

def city
  @city
end

#codeObject (readonly)

Returns the value of attribute code.



3
4
5
# File 'lib/turkish_banks/bank.rb', line 3

def code
  @code
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/turkish_banks/bank.rb', line 3

def name
  @name
end

Instance Method Details

#branchesObject



13
14
15
16
17
18
19
# File 'lib/turkish_banks/bank.rb', line 13

def branches
  nodes = TurkishBanks::DOC.xpath("//sube[bKd= '#{@code}']")
  nodes.map do |node|
    branch_params = Hash.from_xml(node.to_s)['sube']
    TurkishBanks::Branch.new(branch_params)
  end
end