Class: Dovado::Router
- Inherits:
-
Object
- Object
- Dovado::Router
- Includes:
- Celluloid
- Defined in:
- lib/dovado/router.rb,
lib/dovado/router/sms.rb,
lib/dovado/router/info.rb,
lib/dovado/router/traffic.rb,
lib/dovado/router/internet.rb,
lib/dovado/router/services.rb,
lib/dovado/router/info/signal.rb,
lib/dovado/router/sms/message.rb,
lib/dovado/router/sms/messages.rb,
lib/dovado/router/info/operator.rb,
lib/dovado/router/traffic/amount.rb,
lib/dovado/router/info/operator/telia.rb
Overview
A Dovado Router.
Defined Under Namespace
Classes: Info, Internet, Services, Sms, Traffic
Instance Method Summary collapse
-
#info ⇒ Info
Fetch information from the router.
-
#initialize(args = nil) ⇒ Router
constructor
Create a new Router object representing an actual Dovado router on the local network.
-
#internet ⇒ Internet
Get the Internet Connection object.
-
#services ⇒ Services
Fetch services information from the router.
-
#sms ⇒ Sms
Fetch text messages from the router.
-
#traffic ⇒ Traffic
Get the Data Traffic object.
Constructor Details
#initialize(args = nil) ⇒ Router
Create a new Dovado::Router object representing an actual Dovado router on the local network.
The default router options are:
-
Address: 192.168.0.1
-
Port: 6435
-
User: admin
-
Password: password
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/dovado/router.rb', line 22 def initialize(args=nil) @address = '192.168.0.1' # Default address @port = 6435 @user = "admin" # Default username @password = "password" # Default password @connected = false unless args.nil? @address = args[:address] if args.has_key? :address @port = args[:port] if args.has_key? :port @user = args[:user] if args.has_key? :user @password = args[:password] if args.has_key? :password end supervise_client end |
Instance Method Details
#info ⇒ Info
Fetch information from the router.
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/dovado/router.rb', line 89 def info supervise_info router_info = Actor[:router_info] client = Actor[:client] router_info = Actor[:router_info] unless router_info.valid? client.connect unless client.connected? client.authenticate unless client.authenticated? info = client.command('info') router_info.create_from_string info end services router_info rescue ConnectionError => ex Actor[:client].terminate supervise_client supervise_info raise ex end |
#internet ⇒ Internet
Get the Internet Connection object.
71 72 73 74 |
# File 'lib/dovado/router.rb', line 71 def internet Internet.supervise as: :internet, size: 1 unless Actor[:internet] Actor[:internet] end |
#services ⇒ Services
Fetch services information from the router.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/dovado/router.rb', line 42 def services supervise_services client = Actor[:client] router_services = Actor[:router_services] unless router_services.valid? client.connect unless client.connected? client.authenticate unless client.authenticated? string = client.command('services') router_services.create_from_string string end if router_services[:sms] == 'enabled' Sms.supervise as: :sms, size: 1 unless Actor[:sms] sms.enabled = true end router_services rescue ConnectionError => ex Actor[:client].terminate supervise_client supervise_services raise ex end |
#sms ⇒ Sms
Fetch text messages from the router.
113 114 115 116 |
# File 'lib/dovado/router.rb', line 113 def sms Sms.supervise as: :sms, size: 1 unless Actor[:sms] Actor[:sms] end |
#traffic ⇒ Traffic
Get the Data Traffic object.
80 81 82 83 |
# File 'lib/dovado/router.rb', line 80 def traffic Traffic.supervise as: :traffic, size: 1 unless Actor[:traffic] Actor[:traffic] end |