Sha256: 1e50dce9e40e8f2a20ed81948e0d887775e055d56420725426dd77ad0ce882d5

Contents?: true

Size: 787 Bytes

Versions: 1

Compression:

Stored size: 787 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(bank_name).first["banka"]
    end

    def get_branches_of bank_name
      bank(bank_name).first["sube"]
    end 

    private

    def 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.1.0 lib/turkish_banks/turkish_bank.rb