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(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

Parameters:

  • value

    the value to set the attribute download to.



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

Parameters:

  • value

    the value to set the attribute latency to.



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

Parameters:

  • value

    the value to set the attribute offline to.



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

Parameters:

  • value

    the value to set the attribute upload to.



19
20
21
# File 'lib/puppeteer/network_manager.rb', line 19

def upload=(value)
  @upload = value
end

Instance Method Details

#active?Boolean

Returns:

  • (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

#paramsObject



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

#refreshObject



61
62
63
# File 'lib/puppeteer/network_manager.rb', line 61

def refresh
  update_network_conditions
end