Class: Oddb2xml::MedregbmDownloader

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

Instance Attribute Summary

Attributes inherited from Downloader

#agent, #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.



175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/oddb2xml/downloader.rb', line 175

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

Instance Method Details

#downloadObject



188
189
190
191
192
193
194
# File 'lib/oddb2xml/downloader.rb', line 188

def download
  file = "medregbm_#{@type.to_s}.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