module Cmxl
Constants
- VERSION
Public Class Methods
Source
# File lib/cmxl.rb, line 35 def self.parse(data, options = {}) options[:statement_separator] ||= config[:statement_separator] # if no encoding is provided we try to guess using CharDet if options[:encoding].nil? && cd = CharDet.detect(data) options[:encoding] = cd['encoding'] end if options[:encoding] data.encode!('UTF-8', options.delete(:encoding), **options) else data.encode!('UTF-8', **options) unless options.empty? end data.split(options[:statement_separator]).reject { |s| s.strip.empty? }.collect { |s| Cmxl::Statement.new(s.strip) } end
Public: Parse a MT940 string
data - The String containing the MT940 options - Hash with encoding options. Accepts the same parameters as String#encode!
It is likely that you want to provide the encoding of your MT940 String
Examples
Cmxl.parse
(File.read(‘mt940.txt’), encoding: ‘ISO-8859-1’) Cmxl.parse(mt940_string)
Returns an array of Statement
objects