32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/extras_de_cont/rules/revolut.rb', line 32
def parse(text)
transactions = []
current_table = nil
current_lines = []
each_normalized_line(text) do |line|
if (line)
flush_transaction(current_lines, transactions, current_table)
current_table = (line)
next
end
if document_noise?(line)
flush_transaction(current_lines, transactions, current_table)
next
end
if (line)
flush_transaction(current_lines, transactions, current_table)
current_table = nil
next
end
next if ignorable_line?(line)
next if current_table.nil?
if line.match?(DATE_PREFIX)
flush_transaction(current_lines, transactions, current_table)
current_lines = [line]
elsif current_lines.any?
current_lines << line
end
end
flush_transaction(current_lines, transactions, current_table)
transactions
end
|