Sha256: f2e7d5a57152dffd145a57b59a26a8a7a78d8e6193dc8bd349fe2b6776963ac9

Contents?: true

Size: 737 Bytes

Versions: 1

Compression:

Stored size: 737 Bytes

Contents

require 'active_support/core_ext/object/blank'

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

  LOCALE = :de

  attr_accessor :bic, :blz

  class << self

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

    def all
      @@all ||= get_all
    end

    private

      def get_all
        banks = []
        File.open(file, 'r:iso-8859-1').each_line do |line|
          blz = line[0..7]
          bic = line[139..149]
          banks << new(bic: bic, blz: blz)
        end
        banks.uniq
      end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
banking_data-0.9.3 lib/banking_data/german_bank.rb