Class: AdhearsionCpa::ToneDetector
- Inherits:
-
Object
- Object
- AdhearsionCpa::ToneDetector
- Defined in:
- lib/adhearsion_cpa/tone_detector.rb
Instance Attribute Summary collapse
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#tones ⇒ Object
Returns the value of attribute tones.
Instance Method Summary collapse
- #detect_tones(tones, options) ⇒ Object
-
#initialize(controller) ⇒ ToneDetector
constructor
A new instance of ToneDetector.
Constructor Details
#initialize(controller) ⇒ ToneDetector
Returns a new instance of ToneDetector.
6 7 8 |
# File 'lib/adhearsion_cpa/tone_detector.rb', line 6 def initialize(controller) @controller = controller end |
Instance Attribute Details
#timeout ⇒ Object
Returns the value of attribute timeout.
4 5 6 |
# File 'lib/adhearsion_cpa/tone_detector.rb', line 4 def timeout @timeout end |
#tones ⇒ Object
Returns the value of attribute tones.
4 5 6 |
# File 'lib/adhearsion_cpa/tone_detector.rb', line 4 def tones @tones end |
Instance Method Details
#detect_tones(tones, options) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/adhearsion_cpa/tone_detector.rb', line 10 def detect_tones(tones, ) @tones = tones process component.register_event_handler Punchblock::Component::Input::Signal do |event| yield event if block_given? end if async? call.write_and_await_response component if call_alive? if async? call.after(timeout) do if component_running? component.stop! end end component else component.complete_event(timeout).reason end rescue Timeout::Error component.stop! if component_running? nil end |