Class: Oddb2xml::MedregbmDownloader

Inherits:
Downloader show all
Includes:
DownloadMethod
Defined in:
lib/oddb2xml/downloader.rb

Instance Attribute Summary

Attributes inherited from Downloader

#agent, #file2save, #type, #url

Instance Method Summary collapse

Methods inherited from Downloader

#init, #report_download

Constructor Details

#initialize(type = :company) ⇒ MedregbmDownloader

Returns a new instance of MedregbmDownloader.



190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/oddb2xml/downloader.rb', line 190

def initialize(type = :company)
  @type = type
  action = case @type
  when :company # betrieb
    "CreateExcelListBetriebs"
  when :person # medizinalperson
    "CreateExcelListMedizinalPersons"
  else
    ""
  end
  url = "https://www.medregbm.admin.ch/Publikation/#{action}"
  super({}, url)
end

Instance Method Details

#downloadObject



204
205
206
207
208
209
210
# File 'lib/oddb2xml/downloader.rb', line 204

def download
  file = "medregbm_#{@type}.txt"
  download_as(file, "w+:iso-8859-1:utf-8")
  report_download(@url, file)
  FileUtils.rm_f(file, verbose: false) # we need it only in the download
  file
end