Class: Glossarist::Agent::Iho::Downloader
- Inherits:
-
Object
- Object
- Glossarist::Agent::Iho::Downloader
- Defined in:
- lib/glossarist/agent/iho/downloader.rb
Constant Summary collapse
- LANG_MAPPING =
{ fra: { "engFreView.csv" => "http://iho-ohi.net/S32/engFreView.php?operation=ecsv", }, spa: { "engEspView.csv" => "http://iho-ohi.net/S32/engEspView.php?operation=ecsv", }, zho: { "engChnView.csv" => "http://iho-ohi.net/S32/engChnView.php?operation=ecsv", }, ind: { "engIndView.csv" => "http://iho-ohi.net/S32/engIndView.php?operation=ecsv", }, }.freeze
- CSV_URLS =
LANG_MAPPING.values.inject({}) do |acc, x| acc.merge!(x) acc end
Class Method Summary collapse
Instance Method Summary collapse
- #download_csv_files ⇒ Object
-
#initialize(cache_dir, fetch: true) ⇒ Downloader
constructor
A new instance of Downloader.
Constructor Details
#initialize(cache_dir, fetch: true) ⇒ Downloader
Returns a new instance of Downloader.
27 28 29 |
# File 'lib/glossarist/agent/iho/downloader.rb', line 27 def initialize(cache_dir, fetch: true) @cache_downloader = HttpCacheDownloader.new(cache_dir, fetch: fetch) end |
Class Method Details
.lang_code_by_filename(filename) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/glossarist/agent/iho/downloader.rb', line 35 def self.lang_code_by_filename(filename) LANG_MAPPING.each do |lang_code, files| return lang_code if files.key?(filename) end nil end |
Instance Method Details
#download_csv_files ⇒ Object
31 32 33 |
# File 'lib/glossarist/agent/iho/downloader.rb', line 31 def download_csv_files @cache_downloader.download_files(CSV_URLS) end |