Class: Dovado::Router::Internet
- Inherits:
-
Object
- Object
- Dovado::Router::Internet
- Includes:
- Celluloid
- Defined in:
- lib/dovado/router/internet.rb
Overview
Internet Connection.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Internet
constructor
Create a new Internet object.
-
#off! ⇒ Object
Disable internet connection.
-
#off? ⇒ Boolean
Check if the internet connection is down.
-
#on! ⇒ Object
Enable internet connection.
-
#on? ⇒ Boolean
Check if the internet connection is up.
-
#status ⇒ Symbol
Return the current status of the internet connection.
-
#status=(value) ⇒ Object
Set the current status of the internet connection.
Constructor Details
#initialize ⇒ Internet
Create a new Dovado::Router::Internet object.
10 11 12 13 |
# File 'lib/dovado/router/internet.rb', line 10 def initialize @state = ThreadSafe::Cache.new @state[:status] = :offline end |
Class Method Details
.setup_supervision! ⇒ Object
61 62 63 |
# File 'lib/dovado/router/internet.rb', line 61 def self.setup_supervision! supervise as: :internet, size: 1 unless Actor[:internet] end |
Instance Method Details
#off! ⇒ Object
Disable internet connection.
25 26 27 28 29 30 31 |
# 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? ⇒ Boolean
Check if the internet connection is down.
43 44 45 |
# File 'lib/dovado/router/internet.rb', line 43 def off? status == :offline end |
#on! ⇒ Object
Enable internet connection.
16 17 18 19 20 21 22 |
# 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? ⇒ Boolean
Check if the internet connection is up.
36 37 38 |
# File 'lib/dovado/router/internet.rb', line 36 def on? status == :online end |
#status ⇒ Symbol
Return the current status of the internet connection.
50 51 52 |
# File 'lib/dovado/router/internet.rb', line 50 def status @state[:status] end |
#status=(value) ⇒ Object
Set the current status of the internet connection.
57 58 59 |
# File 'lib/dovado/router/internet.rb', line 57 def status=(value) @state[:status] = value end |