Module: Adhearsion::VoIP::Conveniences

Defined in:
lib/adhearsion/voip/conveniences.rb

Instance Method Summary collapse

Instance Method Details

#_(pattern) ⇒ Object

Compiles the provided Asterisk dialplan pattern into a Ruby regular expression. For more usage of Asterisk’s pattern syntax, see www.voip-info.org/wiki/view/Asterisk+Dialplan+Patterns



8
9
10
11
12
13
14
15
# File 'lib/adhearsion/voip/conveniences.rb', line 8

def _(pattern)
  # Uncomment the following code fragment for complete compatibility.
  # The fragment handles the seldom-used hyphen number spacer with no
  # meaning.
	Regexp.new '^' << pattern.# gsub(/(?!\[[\w+-]+)-(?![\w-]+\])/,'').
	  gsub('X', '[0-9]').gsub('Z', '[1-9]').gsub('N','[2-9]').
	  gsub('.','.+').gsub('!','.*') << '$'
end