class NgBankParser::GtbExcel

Public Class Methods

error_message(text) click to toggle source
# File lib/ng-bank-parser/parsers/gtb-excel-parser.rb, line 51
def error_message(text)
        return { 
                status: 400,
                message: text
        }
end
html_parse(file) click to toggle source
# File lib/ng-bank-parser/parsers/gtb-excel-parser.rb, line 24
def html_parse(file)
        data = {}

data[:transactions] = get_transactions_from_html(file)
data[:account_number] = file.css("#lblAcctNo").text().return_first_number
data[:from_date] = file.css("#lblPeriod1").text().convert_string_to_date
data[:to_date] = file.css("#lblPeriod2").text().convert_string_to_date
data[:account_name] = file.css("#lblAcctName").text()
data[:bank_name] = "Guaranty Trust Bank"

      send_response(data)
end
parse(path, password = nil) click to toggle source
# File lib/ng-bank-parser/parsers/gtb-excel-parser.rb, line 8
def parse(path, password = nil)
        accepted_formats = [".xls",".xlsx"];
        unless accepted_formats.include? File.extname(path)
                return error_message("Invalid file format")
        end

        file = read_file_contents(path)
        if (file[:type] == "html")
                html_parse(file[:contents])
        elsif (file[:type] == "xls")
                xls_parse(file[:contents])
        else
                return error_message("Could not parse this file")
        end
end
send_response(data) click to toggle source
# File lib/ng-bank-parser/parsers/gtb-excel-parser.rb, line 58
def send_response(data)
        return {
                status: 200,
                data: data
        }
end
xls_parse(file) click to toggle source
# File lib/ng-bank-parser/parsers/gtb-excel-parser.rb, line 37
def xls_parse(file)
        data = {}

        data[:transactions] = get_transactions_from_excel(file)
data[:account_number] = file.row(10)[0].return_first_number
date_strings = file.row(14)[0].get_date_strings
data[:from_date] = date_strings[0].convert_string_to_date
data[:to_date] = date_strings[1].convert_string_to_date
data[:account_name] = file.row(5)[0]
data[:bank_name] = "Guaranty Trust Bank"

        send_response(data)
end