Class: Adhearsion::VoIP::DSL::PhoneNumber

Inherits:
NumericalString show all
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

#__real_num, #__real_string

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from NumericalString

#==, #initialize, #is_a?, #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.



77
78
79
# File 'lib/adhearsion/voip/dsl/numerical_string.rb', line 77

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.

Returns:

  • (Boolean)


73
# File 'lib/adhearsion/voip/dsl/numerical_string.rb', line 73

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)

Returns:

  • (Boolean)


66
# File 'lib/adhearsion/voip/dsl/numerical_string.rb', line 66

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.

Returns:

  • (Boolean)


69
# File 'lib/adhearsion/voip/dsl/numerical_string.rb', line 69

def us_national_number?() to_s =~ Adhearsion::VoIP::Constants::US_NATIONAL_NUMBER end