Sha256: 925a13460ed7c536e40e5d8c50346307d4b08a0a9ab635686bbf58e4303236b0

Contents?: true

Size: 798 Bytes

Versions: 10

Compression:

Stored size: 798 Bytes

Contents

require 'active_support/core_ext/object/blank'

class BankingData::SwissBank < BankingData::Bank
  extend ActiveModel::Naming
  include ActiveModel::Conversion
  include ActiveModel::AttributeMethods

  LOCALE = :ch

  attr_accessor :bic, :blz

  class << self

    delegate :where, :only, to: :query
    delegate :map, :each, to: :all

    def all
      @@all ||= get_all
    end

    def get_all
      banks = []
      File.read(file, encoding: 'iso-8859-1').lines.each do |line|
        kennzeichen = line[7..10]
        if kennzeichen == '0000'
          blz = line[2..6].strip
          bic = line[284..294]
          banks << new(bic: bic, blz: blz)
        end
      end
      banks.uniq
    end

    def file
      File.dirname(__FILE__) + '/../../data/bcbankenstamm.txt'
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
banking_data-0.9.5 lib/banking_data/swiss_bank.rb
banking_data-0.9.4 lib/banking_data/swiss_bank.rb
banking_data-0.9.3 lib/banking_data/swiss_bank.rb
banking_data-0.9.2 lib/banking_data/swiss_bank.rb
banking_data-0.9.1 lib/banking_data/swiss_bank.rb
banking_data-0.9.0 lib/banking_data/swiss_bank.rb
banking_data-0.8.0 lib/banking_data/swiss_bank.rb
banking_data-0.7.2 lib/banking_data/swiss_bank.rb
banking_data-0.5.1 lib/banking_data/swiss_bank.rb
banking_data-0.5.0 lib/banking_data/swiss_bank.rb