Class: FSR::App::PlayAndGetDigits
- Inherits:
-
Application
- Object
- Application
- FSR::App::PlayAndGetDigits
- Includes:
- FileMethods
- Defined in:
- lib/fsr/app/play_and_get_digits.rb
Constant Summary collapse
- DEFAULT_ARGS =
{:min => 0, :max => 10, :tries => 3, :timeout => 7000, :terminators => ["#"], :chan_var => "fsr_read_dtmf", :regexp => '\d'}
- SENDMSG_METHOD =
%q| def play_and_get_digits(*args, &block) me = super(*args) @read_var = "variable_#{me.chan_var}" sendmsg me @queue.unshift Proc.new { update_session } @queue.unshift(block_given? ? block : lambda {}) end |
Instance Attribute Summary collapse
-
#chan_var ⇒ Object
readonly
Returns the value of attribute chan_var.
Instance Method Summary collapse
- #arguments ⇒ Object
-
#initialize(sound_file, invalid_file, *args) ⇒ PlayAndGetDigits
constructor
args format for array: sound_file, invalid_file, min = 0, max = 10, tries = 3, timeout = 7000, terminators = [“#”], chan_var = “fsr_read_dtmf”, regexp = ‘d’.
- #sendmsg ⇒ Object
Methods included from FileMethods
Methods inherited from Application
Constructor Details
#initialize(sound_file, invalid_file, *args) ⇒ PlayAndGetDigits
args format for array: sound_file, invalid_file, min = 0, max = 10, tries = 3, timeout = 7000, terminators = [“#”], chan_var = “fsr_read_dtmf”, regexp = ‘d’
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/fsr/app/play_and_get_digits.rb', line 16 def initialize(sound_file, invalid_file, *args) #puts args.inspect if args.size == 1 and args.first.kind_of?(Hash) arg_hash = DEFAULT_ARGS.merge(args.first) elsif args.size > 0 # The array used to .zip the args here can be replaced with DEFAULT_ARGS.keys if Hash keys are ordered (1.9) # For now we'll hard code them to preserve order in 1.8/jruby arg_hash = DEFAULT_ARGS.merge(Hash[[:min, :max, :tries, :timeout, :terminators, :chan_var, :regexp][0 .. (args.size-1)].zip(args)]) elsif args.size == 0 arg_hash = DEFAULT_ARGS else raise "Invalid Arguments for PlayAndGetDigits#new (must pass (sound_file, invalid_file, hash) or (sound_file, invalid_file, min = 0, max = 10, tries = 3, timeout = 7000, terminators = ['#'], chan_var = 'fsr_read_dtmf', regexp = '\d'))" end @sound_file = sound_file @invalid_file = invalid_file @min = arg_hash[:min] @max = arg_hash[:max] @tries = arg_hash[:tries] @timeout = arg_hash[:timeout] @chan_var = arg_hash[:chan_var] @terminators = arg_hash[:terminators] @regexp = arg_hash[:regexp] raise unless test_files(@sound_file, @invalid_file) end |
Instance Attribute Details
#chan_var ⇒ Object (readonly)
Returns the value of attribute chan_var.
11 12 13 |
# File 'lib/fsr/app/play_and_get_digits.rb', line 11 def chan_var @chan_var end |
Instance Method Details
#arguments ⇒ Object
43 44 45 |
# File 'lib/fsr/app/play_and_get_digits.rb', line 43 def arguments [@min, @max, @tries, @timeout, @terminators.join(","), @sound_file, @invalid_file, @chan_var, @regexp] end |
#sendmsg ⇒ Object
47 48 49 |
# File 'lib/fsr/app/play_and_get_digits.rb', line 47 def sendmsg "call-command: execute\nexecute-app-name: %s\nexecute-app-arg: %s\nevent-lock:true\n\n" % ["play_and_get_digits", arguments.join(" ")] end |