module Adhearsion::CallController::Utility
Public Instance Methods
grammar_accept(digits = '0123456789
click to toggle source
Utility
method to create a single-digit grammar to accept only some digits
@param [String] digits String representing the digits to accept @return [RubySpeech::GRXML::Grammar] A grammar suitable for use in SSML prompts
@private
# File lib/adhearsion/call_controller/utility.rb, line 35 def grammar_accept(digits = '0123456789#*') allowed_digits = '0123456789#*' gram_digits = digits.chars.select { |x| allowed_digits.include? x } RubySpeech::GRXML.draw :mode => 'dtmf', :root => 'inputdigits' do rule id: 'inputdigits', scope: 'public' do one_of do gram_digits.each { |d| item { d.to_s } } end end end end
grammar_digits(digits = 1)
click to toggle source
Utility
method for DTMF GRXML grammars
@param [Integer] digits Number of digits to accept in the grammar. @return [RubySpeech::GRXML::Grammar] A grammar suitable for use in SSML prompts
@private
# File lib/adhearsion/call_controller/utility.rb, line 16 def grammar_digits(digits = 1) RubySpeech::GRXML.draw :mode => 'dtmf', :root => 'inputdigits' do rule id: 'inputdigits', scope: 'public' do item repeat: digits.to_s do one_of do 0.upto(9) { |d| item { d.to_s } } end end end end end
parse_dtmf(dtmf)
click to toggle source
Parses a DTMF tone string
@param [String] dtmf the tone string to be parsed @return [String] the digits/*/# without any separation
@private
# File lib/adhearsion/call_controller/utility.rb, line 56 def parse_dtmf(dtmf) return if dtmf.nil? dtmf.split(' ').inject '' do |final, digit| final << parse_dtmf_digit(digit) end end
parse_dtmf_digit(digit)
click to toggle source
@private
# File lib/adhearsion/call_controller/utility.rb, line 64 def parse_dtmf_digit(digit) case tone = digit.split('-').last when 'star' '*' when 'pound' '#' else tone end end