Created
July 10, 2012 13:34
-
-
Save kirel/3083270 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module CSVMappings; ... end | |
| module NavisionFtpsConnection; ... end | |
| class CSVImporter | |
| include ... | |
| def initialize(file, clear, sep, etc...) | |
| @file = file, ... | |
| end | |
| def import | |
| prepare_import | |
| iterate_rows do |row| | |
| import_row(row) | |
| end | |
| end | |
| protected | |
| def prepare_import | |
| OptionType Gedöns | |
| clear if @clear | |
| end | |
| def interate_rows | |
| CSV.foreach @file, ... { |row| yield row } | |
| end | |
| def import_row | |
| raise 'abstract' | |
| end | |
| end | |
| class InitialImporter | |
| def initialize file, ... | |
| super file, ... | |
| end | |
| def import_row row | |
| ... | |
| end | |
| end | |
| class NavisionImporter | |
| include ... | |
| def initialize file, ... | |
| super file, ... | |
| end | |
| def import_row row | |
| case row_type(row) | |
| when :article | |
| ... | |
| when :price | |
| ... | |
| when :image | |
| ... | |
| end | |
| end | |
| end | |
| # Usage NavisionImporter.new(file).import |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ja, das sieht schön aus.
Ich weiß auch nicht warum ich mich gescheut habe, das Modul mal zur Klasse zu befördern... Dass der Importer Zustände hat war mir nicht mehr aufgefallen, nachdem alles über Funktionsparameter lief.