Class: CFONB::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/cfonb/parser.rb

Constant Summary collapse

CODES =
[
  PREVIOUS_BALANCE_CODE = '01',
  OPERATION_CODE = '04',
  OPERATION_DETAIL_CODE = '05',
  NEW_BALANCE_CODE = '07',
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(input) ⇒ Parser

Returns a new instance of Parser.



14
15
16
# File 'lib/cfonb/parser.rb', line 14

def initialize(input)
  @input = input
end

Instance Method Details

#parse(optimistic: false) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/cfonb/parser.rb', line 18

def parse(optimistic: false)
  @statements = []
  @current_statement = nil
  @current_operation = nil
  @optimistic = optimistic

  each_line { parse_line(_1) }

  statements
end

#parse_operation(optimistic: false) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/cfonb/parser.rb', line 29

def parse_operation(optimistic: false)
  @current_operation = nil
  @optimistic = optimistic

  each_line { parse_operation_line(_1) }

  current_operation
end