Class: Dovado::Router::Info::Operator
- Inherits:
-
Object
- Object
- Dovado::Router::Info::Operator
- Includes:
- Celluloid
- Defined in:
- lib/dovado/router/info/operator.rb,
lib/dovado/router/info/operator/telia.rb
Overview
An ISP/operator.
Extend this class to create a new operator or use it as it is.
Direct Known Subclasses
Defined Under Namespace
Classes: Telia
Instance Attribute Summary collapse
-
#commands ⇒ Hash
List of commands supported by the operator.
-
#name ⇒ String
Name of the operator.
-
#number ⇒ String
Number to send messages to for the operator.
Class Method Summary collapse
-
.default_commands ⇒ Object
Default commands for an operator.
Instance Method Summary collapse
-
#initialize(args = nil) ⇒ Operator
constructor
Create a new Operator object.
Constructor Details
#initialize(args = nil) ⇒ Operator
Create a new Operator object.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/dovado/router/info/operator.rb', line 43 def initialize(args=nil) self.name = "Unknown" unless args.nil? @number = "" @name = "NoOperator" @commands = Operator.default_commands @number = args[:number] unless args[:number].nil? @name = args[:name] unless args[:name].nil? unless args[:commands].nil? missing_keys = [] Operator.required_commands.each do |req| missing_keys << req unless args[:commands].has_key?(req) end raise ArgumentError.new "Missing required keys in hash: #{Utilities.array_to_sentence(missing_keys)}" unless missing_keys.empty? @commands = args[:commands] end end end |
Instance Attribute Details
#commands ⇒ Hash
List of commands supported by the operator.
30 31 32 |
# File 'lib/dovado/router/info/operator.rb', line 30 def commands @commands end |
#name ⇒ String
Name of the operator.
27 28 29 |
# File 'lib/dovado/router/info/operator.rb', line 27 def name @name end |
#number ⇒ String
Number to send messages to for the operator.
24 25 26 |
# File 'lib/dovado/router/info/operator.rb', line 24 def number @number end |
Class Method Details
.default_commands ⇒ Object
Default commands for an operator.
63 64 65 66 67 68 69 |
# File 'lib/dovado/router/info/operator.rb', line 63 def self.default_commands commands = {} required_commands.each do |command| commands[command] = "" end commands end |