Sha256: 92a77f60e3496d6bf9e1015a034ad017ddfb4f283fb71964fedf033cf8d69e09

Contents?: true

Size: 758 Bytes

Versions: 1

Compression:

Stored size: 758 Bytes

Contents

module MT940Structured
  class Header
    R_RABOBANK = /^:940:/
    R_ABN_AMRO = /ABNANL/
    R_TRIODOS = /^:25:TRIODOSBANK/
    R_ING = /INGBNL/

    def initialize(raw_lines)
      @raw_lines = raw_lines
    end

    def parser
      if @raw_lines[0].match(R_RABOBANK)
        MT940Structured::Parsers::Rabobank::Parser.new
      elsif @raw_lines[0].match(R_ABN_AMRO)
        MT940Structured::Parsers::Abnamro::Parser.new
      elsif @raw_lines[1] && @raw_lines[1].match(R_TRIODOS)
        MT940Structured::Parsers::Triodos::Parser.new
      elsif @raw_lines[0].match(R_ING)
        MT940Structured::Parsers::Ing::Parser.new
      else
        raise UnsupportedBankError.new
      end
    end

  end
  class UnsupportedBankError < StandardError

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
zilverline-mt940-2.0 lib/mt940_structured/header.rb