Class: Puppeteer::NetworkManager::InternalNetworkCondition

Inherits:
Object
  • Object
show all
Defined in:
lib/puppeteer/network_manager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ InternalNetworkCondition

Returns a new instance of InternalNetworkCondition.



19
20
21
22
23
24
25
# File 'lib/puppeteer/network_manager.rb', line 19

def initialize(client)
  @client = client
  @offline = false
  @upload = -1
  @download = -1
  @latency = 0
end

Instance Attribute Details

#download=(value) ⇒ Object (writeonly)

Sets the attribute download

Parameters:

  • value

    the value to set the attribute download to.



17
18
19
# File 'lib/puppeteer/network_manager.rb', line 17

def download=(value)
  @download = value
end

#latency=(value) ⇒ Object (writeonly)

Sets the attribute latency

Parameters:

  • value

    the value to set the attribute latency to.



17
18
19
# File 'lib/puppeteer/network_manager.rb', line 17

def latency=(value)
  @latency = value
end

#offline=(value) ⇒ Object (writeonly)

Sets the attribute offline

Parameters:

  • value

    the value to set the attribute offline to.



17
18
19
# File 'lib/puppeteer/network_manager.rb', line 17

def offline=(value)
  @offline = value
end

#upload=(value) ⇒ Object (writeonly)

Sets the attribute upload

Parameters:

  • value

    the value to set the attribute upload to.



17
18
19
# File 'lib/puppeteer/network_manager.rb', line 17

def upload=(value)
  @upload = value
end

Instance Method Details

#network_condition=(network_condition) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/puppeteer/network_manager.rb', line 33

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



27
28
29
30
31
# File 'lib/puppeteer/network_manager.rb', line 27

def offline_mode=(value)
  return if @offline == value
  @offline = value
  update_network_conditions
end