Sha256: bdbaa0cbc8a4ff3afa34e11c7d6c39c8ba9080336ae14bf55a1bdfff1683fdf1

Contents?: true

Size: 933 Bytes

Versions: 1

Compression:

Stored size: 933 Bytes

Contents

require "turkish_support"

module TurkishBanks
  class TurkishBank
    using TurkishSupport
    attr_accessor :last_update_date, :banks

    BANKS_URL = "http://eft.tcmb.gov.tr/bankasubelistesi/bankaSubeTumListe.xml"    
    
    def initialize
      doc = Nokogiri.XML(open(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

    def get_information_of bank_name
      bank = get_bank(bank_name).first["banka"]
      TurkishBanks::Bank.new bank
    end

    def get_branches_of bank_name
      branches = get_bank(bank_name).first["sube"]
      branches.each do |branch|
        TurkishBanks::Branch.new branch
      end
    end

    private

    def get_bank bank_name
      @banks.select {|b| b["banka"]["bAd"] == bank_name.upcase}
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
turkish_banks-0.2.0 lib/turkish_banks/turkish_bank.rb