Sha256: 16dea3b82f15e8cf9c4b3f94419f082c4c2034ea0d056a6f6f17ad0b1d2db12a

Contents?: true

Size: 758 Bytes

Versions: 1

Compression:

Stored size: 758 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

    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
    end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
banking_data-0.4.0 lib/banking_data/swiss_bank.rb