Class: Torasup::Operator
- Inherits:
-
Object
- Object
- Torasup::Operator
- Defined in:
- lib/torasup/operator.rb
Instance Attribute Summary collapse
-
#area_code ⇒ Object
Returns the value of attribute area_code.
-
#country_code ⇒ Object
Returns the value of attribute country_code.
-
#full_number ⇒ Object
Returns the value of attribute full_number.
-
#local_number ⇒ Object
Returns the value of attribute local_number.
-
#prefix ⇒ Object
Returns the value of attribute prefix.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(country_code, area_code_or_prefix, unresolved_local_number) ⇒ Operator
constructor
A new instance of Operator.
- #method_missing(method, interpolations = {}) ⇒ Object
Constructor Details
#initialize(country_code, area_code_or_prefix, unresolved_local_number) ⇒ Operator
Returns a new instance of Operator.
5 6 7 8 9 |
# File 'lib/torasup/operator.rb', line 5 def initialize(country_code, area_code_or_prefix, unresolved_local_number) self.country_code = country_code self.full_number = full_prefix(area_code_or_prefix, unresolved_local_number) parse_phone_number(area_code_or_prefix, unresolved_local_number) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, interpolations = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/torasup/operator.rb', line 11 def method_missing(method, interpolations = {}) value = Torasup.prefix_data(full_prefix)[method.to_s] return value unless value.is_a?(String) interpolated_result = value.dup interpolations.each do |interpolation, interpolated_value| interpolated_result.gsub!("%{#{interpolation}}", interpolated_value.to_s) end interpolated_result end |
Instance Attribute Details
#area_code ⇒ Object
Returns the value of attribute area_code.
3 4 5 |
# File 'lib/torasup/operator.rb', line 3 def area_code @area_code end |
#country_code ⇒ Object
Returns the value of attribute country_code.
3 4 5 |
# File 'lib/torasup/operator.rb', line 3 def country_code @country_code end |
#full_number ⇒ Object
Returns the value of attribute full_number.
3 4 5 |
# File 'lib/torasup/operator.rb', line 3 def full_number @full_number end |
#local_number ⇒ Object
Returns the value of attribute local_number.
3 4 5 |
# File 'lib/torasup/operator.rb', line 3 def local_number @local_number end |
#prefix ⇒ Object
Returns the value of attribute prefix.
3 4 5 |
# File 'lib/torasup/operator.rb', line 3 def prefix @prefix end |
Class Method Details
.all ⇒ Object
25 26 27 |
# File 'lib/torasup/operator.rb', line 25 def self.all (:prefixes) end |
.registered ⇒ Object
21 22 23 |
# File 'lib/torasup/operator.rb', line 21 def self.registered (:registered_operator_prefixes) end |