Sha256: a57ed16c811df67bbd24c3bb85bd7f900922c73a23a4b9bee79a49efe2b9bc23

Contents?: true

Size: 1017 Bytes

Versions: 1

Compression:

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

    def all
      @@all ||= get_all
    end

    def get_all
      banks = []
      SmarterCSV.process(file, opts).each do |line|
        if line[:kennzeichen] == 'Hauptanstalt'
          blz = line[:bankleitzahl].try(:gsub, /"/, '')
          bic = line[:'swift-code'].try(:gsub, /"/, '')
          banks << new(bic: bic, blz: blz)
        end
      end
      banks
    end

    private

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

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