Sha256: 91b221c07f8088f940df2ea3b00caad3e34aed4d11407f121696e62fde626600

Contents?: true

Size: 641 Bytes

Versions: 1

Compression:

Stored size: 641 Bytes

Contents

module MT940Structured
  class Parser
    def self.parse_mt940(path, join_lines_by = ' ')
      file_content = FileContent.new(readfile(path), join_lines_by)
      grouped_lines = file_content.group_lines
      file_content.get_header.parser.transform(grouped_lines)
    end

    private
    def self.readfile(path)
      File.open(path).readlines.map do |line|
        line
          .encode('UTF-8', 'binary', :invalid => :replace, :undef => :replace) # remove other obscure chars. god knows what people upload.
          .gsub(/\u001A/, '') # remove eof chars in the middle of the string... yes it happens :-(
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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