Sha256: 110bcb70cb75abd2681a88995cd87640d3124d9d9cce88549c174d0bbd0eebea

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

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].try(:gsub, /"/, '')
        bic = line[:'swift_code'].try(:gsub, /"/, '')
        if blz && bic
          banks << new(bic: bic, blz: blz)
        end
      end
      banks.uniq
    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.5.1 lib/banking_data/austrian_bank.rb