Sha256: 59f420feb1e9e2681eff5e0600ffff58dd6ee1e5d315269af9ff900ce7d62455

Contents?: true

Size: 951 Bytes

Versions: 1

Compression:

Stored size: 951 Bytes

Contents

require 'active_support/core_ext/object/blank'

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

  LOCALE = :nl

  attr_accessor :bank_id, :bic, :name

  class << self

    delegate :where, :only, to: :query
    delegate :map, :each, to: :all

    def all
      @@all ||= get_all
    end

    private

    def get_all
      banks = []
      SmarterCSV.process(file, opts).each do |line|
        bank_id = line[:identifier].to_s
        bic = line[:bic]
        name = line[:naam_betaaldienstverlener].to_s
        if bank_id && bic && name
          banks << new(name: name, bank_id: bank_id, bic: bic)
        end
      end
      banks.uniq
    end

    private

    def file
      File.dirname(__FILE__) +
        '/../../data/BIC-lijst-NL.csv'
    end

    def opts
      {
        col_sep: ',',
        skip_lines: 1
      }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
banking_data-0.9.5 lib/banking_data/dutch_bank.rb