module BankStatementParser
This file is part of bank_statement_parser.
bank_statement_parser is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
bank_statement_parser is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with bank_statement_parser. If not, see <www.gnu.org/licenses/>.
This file is part of bank_statement_parser.
bank_statement_parser is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
bank_statement_parser is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with bank_statement_parser. If not, see <www.gnu.org/licenses/>.
Public Class Methods
# File lib/bank_statement_parser.rb, line 30 def self.logger @@logger ||= Logger.new(STDERR) end
# File lib/bank_statement_parser.rb, line 33 def self.logger=(logger) @@logger = logger end
Parse the specified statement file, for the specified (by symbol) bank
Returns an instance of BankStatement
# File lib/bank_statement_parser.rb, line 40 def self.parse path, bank_symbol = :hsbc parser = parser_factory(bank_symbol) parser.parse path return parser.bank_statement end
Create a parser for the specified bank
# File lib/bank_statement_parser.rb, line 48 def self.parser_factory(bank_symbol) bank = @@banks[bank_symbol] or raise "Unknown bank #{bank_symbol}" parser_class = Kernel.const_get(self.name + '::' + bank) raise "No parser for #{bank} statements" unless Class == parser_class.class parser = parser_class.new raise "Invalid parser class" unless parser.is_a?(BankStatementParser::Base) parser end
# File lib/bank_statement_parser.rb, line 26 def self.register_bank(key, val) @@banks[key] = val end