class Dovado::Router::Internet
Internet
Connection.
@since 1.0.3
Public Class Methods
new()
click to toggle source
Create a new {Internet} object.
# File lib/dovado/router/internet.rb, line 10 def initialize @state = ThreadSafe::Cache.new @state[:status] = :offline end
setup_supervision!()
click to toggle source
# File lib/dovado/router/internet.rb, line 61 def self.setup_supervision! supervise as: :internet, size: 1 unless Actor[:internet] end
Public Instance Methods
off!()
click to toggle source
Disable internet connection.
# File lib/dovado/router/internet.rb, line 25 def off! client = Actor[:client] client.connect unless client.connected? client.authenticate unless client.authenticated? client.command("internet off") status = :offline end
off?()
click to toggle source
Check if the internet connection is down.
@return [Boolean] true
if internet was disabled, false otherwise.
# File lib/dovado/router/internet.rb, line 43 def off? status == :offline end
on!()
click to toggle source
Enable internet connection.
# File lib/dovado/router/internet.rb, line 16 def on! client = Actor[:client] client.connect unless client.connected? client.authenticate unless client.authenticated? client.command("internet on") status = :online end
on?()
click to toggle source
Check if the internet connection is up.
@return [Boolean] true
if internet was enabled, false otherwise.
# File lib/dovado/router/internet.rb, line 36 def on? status == :online end
status()
click to toggle source
Return the current status of the internet connection.
@return [Symbol] one of: :online
or :offline
# File lib/dovado/router/internet.rb, line 50 def status @state[:status] end
status=(value)
click to toggle source
Set the current status of the internet connection.
@param [Symbol] value one of: :online
or :offline
# File lib/dovado/router/internet.rb, line 57 def status=(value) @state[:status] = value end