Sha256: 574b1155687b54f5d6ec7d83af6fd688a069d60e56983838de4ad4787022ef3c

Contents?: true

Size: 953 Bytes

Versions: 5

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_1502983225066.csv'
      end

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
banking_data-0.9.2 lib/banking_data/austrian_bank.rb
banking_data-0.9.1 lib/banking_data/austrian_bank.rb
banking_data-0.9.0 lib/banking_data/austrian_bank.rb
banking_data-0.8.0 lib/banking_data/austrian_bank.rb
banking_data-0.7.2 lib/banking_data/austrian_bank.rb