Class: Adhearsion::VoIP::DSL::PhoneNumber
- Inherits:
-
NumericalString
- Object
- NumericalString
- Adhearsion::VoIP::DSL::PhoneNumber
- Defined in:
- lib/adhearsion/voip/dsl/numerical_string.rb
Overview
The PhoneNumber class is used by one object throughout Adhearsion: the AGI “extension” variable. Using some clevery Ruby hackery, the Extension class allows dialplan writers to use the best of Fixnum and String usage such as
-
Dialing international numbers
-
Using a regexp in a case statement for “extension”
-
Using a numerical range against extension – e.g. (100…200)
-
Using the thousands separator
Instance Attribute Summary
Attributes inherited from NumericalString
Class Method Summary collapse
-
.from_vanity(str) ⇒ Object
Useful for dialing those 1-800-FUDGEME type numbers with letters in them.
Instance Method Summary collapse
-
#isn? ⇒ Boolean
Checks against a pattern identifying an ISN number.
-
#us_local_number? ⇒ Boolean
Checks against a pattern identifying US local numbers (i.e numbers without an area code seven digits long).
-
#us_national_number? ⇒ Boolean
Checks against a pattern identifying US domestic numbers.
Methods inherited from NumericalString
#initialize, #method_missing, #respond_to?, starts_with_leading_zero?
Constructor Details
This class inherits a constructor from Adhearsion::VoIP::DSL::NumericalString
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Adhearsion::VoIP::DSL::NumericalString
Class Method Details
.from_vanity(str) ⇒ Object
Useful for dialing those 1-800-FUDGEME type numbers with letters in them. Letters in the argument will be converted to their appropriate keypad key.
64 65 66 |
# File 'lib/adhearsion/voip/dsl/numerical_string.rb', line 64 def self.from_vanity str str.gsub(/\W/, '').upcase.tr('A-Z', '22233344455566677778889999') end |
Instance Method Details
#isn? ⇒ Boolean
Checks against a pattern identifying an ISN number. See freenum.org for more info.
60 |
# File 'lib/adhearsion/voip/dsl/numerical_string.rb', line 60 def isn?() to_s =~ Adhearsion::VoIP::Constants::ISN end |
#us_local_number? ⇒ Boolean
Checks against a pattern identifying US local numbers (i.e numbers without an area code seven digits long)
53 |
# File 'lib/adhearsion/voip/dsl/numerical_string.rb', line 53 def us_local_number?() to_s =~ Adhearsion::VoIP::Constants::US_LOCAL_NUMBER end |
#us_national_number? ⇒ Boolean
Checks against a pattern identifying US domestic numbers.
56 |
# File 'lib/adhearsion/voip/dsl/numerical_string.rb', line 56 def us_national_number?() to_s =~ Adhearsion::VoIP::Constants::US_NATIONAL_NUMBER end |