Class: SpeedtestNet::Download

Inherits:
Object
  • Object
show all
Defined in:
lib/speedtest_net/download.rb

Constant Summary collapse

FILES =
%w[random350x350.jpg random500x500.jpg random1000x1000.jpg
random1500x1500.jpg random2000x2000.jpg random3000x3000.jpg
random3500x3500.jpg random4000x4000.jpg].freeze

Class Method Summary collapse

Class Method Details

.measure(server, timeout: HTTP_TIMEOUT) ⇒ Object

rubocop:disable Metrics/MethodLength



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/speedtest_net/download.rb', line 17

def measure(server, timeout: HTTP_TIMEOUT) # rubocop:disable Metrics/MethodLength
  config = Config.fetch
  concurrent_number = config.download[:threadsperurl]

  results = []
  begin
    Timeout.timeout(timeout) do
      FILES.each do |file|
        urls = create_urls(server, file, concurrent_number)
        results << multi_downloader(urls)
      end
    end
  rescue Timeout::Error # rubocop:disable Lint/SuppressedException
  end
  MeasureResult.new(results)
end