Class: MT940::Base
- Inherits:
-
Object
- Object
- MT940::Base
- Defined in:
- lib/mt940/base.rb
Instance Attribute Summary collapse
-
#bank ⇒ Object
Returns the value of attribute bank.
-
#transactions ⇒ Object
Returns the value of attribute transactions.
Instance Method Summary collapse
-
#initialize(file) ⇒ Base
constructor
A new instance of Base.
- #parse ⇒ Object
Constructor Details
#initialize(file) ⇒ Base
Returns a new instance of Base.
12 13 14 15 16 17 18 19 |
# File 'lib/mt940/base.rb', line 12 def initialize(file) @transactions, @lines = [], [] @bank = self.class.to_s.split('::').last file.readlines.each do |line| line.encode!('UTF-8', 'UTF-8', :invalid => :replace) begin_of_line?(line) ? @lines << line : @lines[-1] += line end end |
Instance Attribute Details
#bank ⇒ Object
Returns the value of attribute bank.
10 11 12 |
# File 'lib/mt940/base.rb', line 10 def bank @bank end |
#transactions ⇒ Object
Returns the value of attribute transactions.
10 11 12 |
# File 'lib/mt940/base.rb', line 10 def transactions @transactions end |
Instance Method Details
#parse ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/mt940/base.rb', line 21 def parse @lines.each do |line| @line = line.strip.gsub(/\n|\r/,'').gsub(/\s{2,}/,' ') if @line.match(/^:(\d{2}F?):/) case $1 when '25' parse_tag_25 when '60F' parse_tag_60F when '61' parse_tag_61 @transactions << @transaction if @transaction when '86' parse_tag_86 if @transaction when '62F' @transaction = nil #Ignore 'eindsaldo' end end end end |