Sha256: 3d31039e149684a5c0931912997c1294f6c918e8773cba531d36a147060a2d53

Contents?: true

Size: 953 Bytes

Versions: 1

Compression:

Stored size: 953 Bytes

Contents

require 'active_support/core_ext/object/blank'
require 'active_support/core_ext/object/try'

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

  LOCALE = :at

  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 = []
      SmarterCSV.process(file, opts).each do |line|
        blz = line[:bankleitzahl].to_s
        bic = line[:'swift_code']
        if blz && bic
          banks << new(bic: bic, blz: blz)
        end
      end
      banks.uniq
    end

    private

      def file
        File.dirname(__FILE__) +
          '/../../data/SEPA-ZV-VZ_gesamt_de_1615904610976.csv'
      end

      def opts
        {
          col_sep: ';',
          file_encoding: 'iso-8859-1'
        }
      end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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