Class: Puppeteer::NetworkManager::InternalNetworkCondition
- Inherits:
-
Object
- Object
- Puppeteer::NetworkManager::InternalNetworkCondition
- Defined in:
- lib/puppeteer/network_manager.rb
Instance Attribute Summary collapse
-
#download ⇒ Object
writeonly
Sets the attribute download.
-
#latency ⇒ Object
writeonly
Sets the attribute latency.
-
#offline ⇒ Object
writeonly
Sets the attribute offline.
-
#upload ⇒ Object
writeonly
Sets the attribute upload.
Instance Method Summary collapse
- #active? ⇒ Boolean
-
#initialize(sender) ⇒ InternalNetworkCondition
constructor
A new instance of InternalNetworkCondition.
- #network_condition=(network_condition) ⇒ Object
- #offline_mode=(value) ⇒ Object
- #params ⇒ Object
- #refresh ⇒ Object
Constructor Details
#initialize(sender) ⇒ InternalNetworkCondition
Returns a new instance of InternalNetworkCondition.
21 22 23 24 25 26 27 |
# File 'lib/puppeteer/network_manager.rb', line 21 def initialize(sender) @sender = sender @offline = false @upload = -1 @download = -1 @latency = 0 end |
Instance Attribute Details
#download=(value) ⇒ Object (writeonly)
Sets the attribute download
19 20 21 |
# File 'lib/puppeteer/network_manager.rb', line 19 def download=(value) @download = value end |
#latency=(value) ⇒ Object (writeonly)
Sets the attribute latency
19 20 21 |
# File 'lib/puppeteer/network_manager.rb', line 19 def latency=(value) @latency = value end |
#offline=(value) ⇒ Object (writeonly)
Sets the attribute offline
19 20 21 |
# File 'lib/puppeteer/network_manager.rb', line 19 def offline=(value) @offline = value end |
#upload=(value) ⇒ Object (writeonly)
Sets the attribute upload
19 20 21 |
# File 'lib/puppeteer/network_manager.rb', line 19 def upload=(value) @upload = value end |
Instance Method Details
#active? ⇒ Boolean
57 58 59 |
# File 'lib/puppeteer/network_manager.rb', line 57 def active? @offline || @latency != 0 || @download != -1 || @upload != -1 end |
#network_condition=(network_condition) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/puppeteer/network_manager.rb', line 35 def network_condition=(network_condition) if network_condition @upload = network_condition.upload @download = network_condition.download @latency = network_condition.latency else @upload = -1 @download = -1 @latency = 0 end update_network_conditions end |
#offline_mode=(value) ⇒ Object
29 30 31 32 33 |
# File 'lib/puppeteer/network_manager.rb', line 29 def offline_mode=(value) return if @offline == value @offline = value update_network_conditions end |
#params ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/puppeteer/network_manager.rb', line 48 def params { offline: @offline, latency: @latency, downloadThroughput: @download, uploadThroughput: @upload, } end |
#refresh ⇒ Object
61 62 63 |
# File 'lib/puppeteer/network_manager.rb', line 61 def refresh update_network_conditions end |