Class: MT940Structured::FileContent
- Inherits:
-
Object
- Object
- MT940Structured::FileContent
- Defined in:
- lib/mt940_structured/file_content.rb
Constant Summary collapse
- R_EOF_ING =
/^-XXX$/
- R_EOF_ABN_AMRO =
/^-$/
- R_EOF_TRIODOS =
/^-$/
Instance Method Summary collapse
- #get_header ⇒ Object
- #group_lines ⇒ Object
-
#initialize(raw_lines, join_lines_by = ' ') ⇒ FileContent
constructor
A new instance of FileContent.
Constructor Details
#initialize(raw_lines, join_lines_by = ' ') ⇒ FileContent
Returns a new instance of FileContent.
6 7 8 9 |
# File 'lib/mt940_structured/file_content.rb', line 6 def initialize(raw_lines, join_lines_by = ' ') @raw_lines = raw_lines.map{|line|line.strip} @join_lines_by = join_lines_by end |
Instance Method Details
#get_header ⇒ Object
11 12 13 |
# File 'lib/mt940_structured/file_content.rb', line 11 def get_header MT940Structured::Header.new(@raw_lines) end |
#group_lines ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/mt940_structured/file_content.rb', line 15 def group_lines body_lines = @raw_lines[start_index..(end_index-1)] grouped_lines = [] previous_tag = nil body_lines.each do |line| mt940_line = line.match /^(:\d{2}[D|C|F|M]?:)/ if mt940_line && previous_tag != $1 previous_tag = $1 grouped_lines << line else next_line = if line.match /^(:\d{2}[D|C|F|M]?:)(.*)/ $2 else line end grouped_lines[-1] = [grouped_lines.last, @join_lines_by, next_line].join end end grouped_lines end |