Class: TurkishBanks::TurkishBank
- Inherits:
-
Object
- Object
- TurkishBanks::TurkishBank
- Defined in:
- lib/turkish_banks/turkish_bank.rb
Constant Summary collapse
- BANKS_URL =
"http://eftemkt.tcmb.gov.tr/bankasubelistesi/bankaSubeTumListe.xml".freeze
Instance Attribute Summary collapse
-
#banks ⇒ Object
Returns the value of attribute banks.
-
#last_update_date ⇒ Object
Returns the value of attribute last_update_date.
Instance Method Summary collapse
- #get_branches_of(bank_name) ⇒ Object
- #get_information_of(bank_name) ⇒ Object
-
#initialize ⇒ TurkishBank
constructor
A new instance of TurkishBank.
Constructor Details
#initialize ⇒ TurkishBank
Returns a new instance of TurkishBank.
7 8 9 10 11 12 13 |
# File 'lib/turkish_banks/turkish_bank.rb', line 7 def initialize doc = Nokogiri.XML(::OpenURI.open_uri(BANKS_URL), nil, 'UTF-8') doc.remove_namespaces! response = Hash.from_xml(doc.to_s) @last_update_date = response["bankaSubeTumListe"]["tarih"] @banks = response["bankaSubeTumListe"]["bankaSubeleri"] end |
Instance Attribute Details
#banks ⇒ Object
Returns the value of attribute banks.
3 4 5 |
# File 'lib/turkish_banks/turkish_bank.rb', line 3 def banks @banks end |
#last_update_date ⇒ Object
Returns the value of attribute last_update_date.
3 4 5 |
# File 'lib/turkish_banks/turkish_bank.rb', line 3 def last_update_date @last_update_date end |
Instance Method Details
#get_branches_of(bank_name) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/turkish_banks/turkish_bank.rb', line 22 def get_branches_of(bank_name) return "#{bank_name} isminde bir bankaya ait şube bilgisi bulunamadı." if get_bank(bank_name).empty? bank_branches = [] branches = get_bank(bank_name).first["sube"] branches.each do |branch| bank_branches << TurkishBanks::Branch.new(branch) end bank_branches end |
#get_information_of(bank_name) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/turkish_banks/turkish_bank.rb', line 15 def get_information_of(bank_name) return "#{bank_name} isminde bir banka bulunamadı." if get_bank(bank_name).empty? bank = get_bank(bank_name).first["banka"] TurkishBanks::Bank.new bank end |