class BankTools::DE::BLZDownloader
Public Instance Methods
run()
click to toggle source
# File lib/banktools-de/blz_downloader.rb, line 15 def run puts "Download: #{url}" if url.include?("://") puts "Downloading…" local_file = "/tmp/blz.xlsx" File.write(local_file, URI.open(url).read) else local_file = url end puts "Parsing…" book = Creek::Book.new(local_file) sheet = book.sheets[0] hash = { generated_at: Time.now, generated_from_url: url, data: {} } data = hash[:data] sheet.rows.each_with_index do |row, index| blz, feature, name, plz, location, short_name, *_ = row.values next if index.zero? && blz.match(/\D/) # Headers data[blz] = short_name end File.write("data/blz_to_name.yml", hash.to_yaml) puts "Done. Wrote #{data.length} entries." end