Module: SpeedtestNet

Defined in:
lib/speedtest_net.rb,
lib/speedtest_net/geo.rb,
lib/speedtest_net/error.rb,
lib/speedtest_net/client.rb,
lib/speedtest_net/config.rb,
lib/speedtest_net/result.rb,
lib/speedtest_net/server.rb,
lib/speedtest_net/upload.rb,
lib/speedtest_net/latency.rb,
lib/speedtest_net/version.rb,
lib/speedtest_net/download.rb,
lib/speedtest_net/user_agent.rb,
lib/speedtest_net/http_timeout.rb,
lib/speedtest_net/measure_result.rb,
lib/speedtest_net/formatter/speed.rb,
lib/speedtest_net/formatter/latency.rb,
lib/speedtest_net/formatter/distance.rb

Defined Under Namespace

Modules: Formatter Classes: Client, Config, Download, Error, Geo, HTTPDownloadError, InvalidServerIdError, Latency, MeasureResult, Result, Server, Upload

Constant Summary collapse

VERSION =
'0.9.2'
USER_AGENT =
"SpeedtestNet/#{VERSION}".freeze
HTTP_TIMEOUT =
180

Class Method Summary collapse

Class Method Details

.list_serverObject



22
23
24
# File 'lib/speedtest_net.rb', line 22

def self.list_server
  Server.list
end

.run(id = nil, exclude_server_ids: [], timeout: HTTP_TIMEOUT) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/speedtest_net.rb', line 12

def self.run(id = nil, exclude_server_ids: [], timeout: HTTP_TIMEOUT)
  config = Config.fetch
  server = Server.select_server(id, exclude_server_ids)
  download_results = Download.measure(server, timeout: timeout)
  upload_results = Upload.measure(server, timeout: timeout)

  Config.clear_cache
  Result.new(config.client, server, download_results, upload_results)
end