Sha256: e38df38b58d3a2324e2e56bb87357f1afb7f8d6a97455c221fa5d48edb91acda

Contents?: true

Size: 696 Bytes

Versions: 2

Compression:

Stored size: 696 Bytes

Contents

class Ibanizator
  class Iban
    module ExtendedData
      class DE
        attr_reader :iban
        include Equalizer.new(:iban)
        include Adamantium

        def initialize(iban)
          raise Invalid, "Can't compute extended data on invalid IBAN!" unless iban.valid?
          @iban = iban
        end

        def bank_code
          iban.to_s[4..11]
        end
        memoize :bank_code

        def account_number
          iban.to_s[12..-1].gsub(/\A0+/, '')
        end
        memoize :account_number

        def bic
          Ibanizator.bank_db.bank_by_bank_code(bank_code).bic
        end
        memoize :bic
      end
    end # ExtendedData
  end # Iban
end # Ibanizator

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dkd-ibanizator-0.10.0 lib/ibanizator/iban/extended_data/de.rb
dkd-ibanizator-0.9.0 lib/ibanizator/iban/extended_data/de.rb