Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refactored Ocr class for clarity

  • Loading branch information...
commit a2f103f2fa89d868d56d83c86e35e925d95b049f 1 parent 17013f5
@guyroyse authored
Showing with 12 additions and 7 deletions.
  1. +12 −7 lib/ocr.rb
View
19 lib/ocr.rb
@@ -9,15 +9,20 @@ def initialize
end
def scan file
read_file file
- (0...count_account_numbers).each do |account|
- account_text = extract_account_text account
- @accounts << parse_account_number(account_text)
- end
+ parse_accounts
end
def read_file file
- File.open file do |file| @scanned = file.read end
+ File.open file do |file|
+ @scanned = file.read
+ end
+ end
+ def parse_accounts
+ (0...count_accounts).each do |account|
+ account_text = extract_account_text account
+ @accounts << parse_account(account_text)
+ end
end
- def count_account_numbers
+ def count_accounts
count_lines / 4
end
def count_lines
@@ -27,7 +32,7 @@ def extract_account_text acct_position
acct_offset = acct_position * ACCOUNT_LENGTH
@scanned[acct_offset, ACCOUNT_LENGTH]
end
- def parse_account_number account_text
+ def parse_account account_text
account = Account.new
account.parse_number account_text
account
Please sign in to comment.
Something went wrong with that request. Please try again.