Class: BankOCR::FileParser
- Inherits:
-
Object
- Object
- BankOCR::FileParser
- Defined in:
- lib/file_parser.rb
Overview
Reads a file from OCR and converts to digits
Instance Method Summary collapse
- #entries ⇒ Object
-
#initialize(input_path) ⇒ FileParser
constructor
A new instance of FileParser.
- #read_entries ⇒ Object
Constructor Details
#initialize(input_path) ⇒ FileParser
Returns a new instance of FileParser.
4 5 6 |
# File 'lib/file_parser.rb', line 4 def initialize(input_path) @input_path = input_path end |
Instance Method Details
#entries ⇒ Object
8 9 10 |
# File 'lib/file_parser.rb', line 8 def entries @digits || read_entries end |
#read_entries ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/file_parser.rb', line 12 def read_entries @digits = [] file = File.open(@input_path) @digits << parse_entry(file) until file.eof? @digits.map { |d| BankOCR::AccountNumber.new(d) } rescue p 'Error reading input file, please validate' [] ensure file.close if file end |