Sha256: 504de47c6c8881a5262b8a08c8236bfa8f25e51ad02ed2945b1ef5561a92054b

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_2021_03_16.txt'
      end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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