Class: Hvor::Downloader

Inherits:
Object
  • Object
show all
Defined in:
app/services/hvor/downloader.rb

Overview

Downloads an IP2Location LITE CSV zip archive for the given product code (e.g. "DB1LITECSV", "DB1LITECSVIPV6") and returns it as a Tempfile. The caller is responsible for closing/unlinking the Tempfile.

Constant Summary collapse

MAX_REDIRECTS =
5

Instance Method Summary collapse

Constructor Details

#initialize(product_code, timeout: Hvor.configuration.download_timeout) ⇒ Downloader

Returns a new instance of Downloader.



14
15
16
17
# File 'app/services/hvor/downloader.rb', line 14

def initialize(product_code, timeout: Hvor.configuration.download_timeout)
  @product_code = product_code
  @timeout = timeout
end

Instance Method Details

#callObject



19
20
21
# File 'app/services/hvor/downloader.rb', line 19

def call
  fetch(download_uri, MAX_REDIRECTS)
end