Class: SpeedtestNet::Result

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, server, download_result, upload_result) ⇒ Result

Returns a new instance of Result.



11
12
13
14
15
16
# File 'lib/speedtest_net/result.rb', line 11

def initialize(client, server, download_result, upload_result)
  @client = client
  @server = server
  @download_result = download_result
  @upload_result = upload_result
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



9
10
11
# File 'lib/speedtest_net/result.rb', line 9

def client
  @client
end

#serverObject (readonly)

Returns the value of attribute server.



9
10
11
# File 'lib/speedtest_net/result.rb', line 9

def server
  @server
end

Instance Method Details

#distanceObject



42
43
44
# File 'lib/speedtest_net/result.rb', line 42

def distance
  @server.distance
end

#downloadObject



18
19
20
# File 'lib/speedtest_net/result.rb', line 18

def download
  @download_result.calculate
end

#latencyObject



34
35
36
# File 'lib/speedtest_net/result.rb', line 34

def latency
  @server.latency
end

#pretty_distanceObject



46
47
48
# File 'lib/speedtest_net/result.rb', line 46

def pretty_distance
  Formatter::Distance.call(distance)
end

#pretty_downloadObject



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

def pretty_download
  Formatter::Speed.call(download)
end

#pretty_latencyObject



38
39
40
# File 'lib/speedtest_net/result.rb', line 38

def pretty_latency
  Formatter::Latency.call(latency)
end

#pretty_uploadObject



30
31
32
# File 'lib/speedtest_net/result.rb', line 30

def pretty_upload
  Formatter::Speed.call(upload)
end

#uploadObject



26
27
28
# File 'lib/speedtest_net/result.rb', line 26

def upload
  @upload_result.calculate
end