Class: Twilio::Rails::Phone::Tree::Gather
- Inherits:
-
Object
- Object
- Twilio::Rails::Phone::Tree::Gather
- Defined in:
- lib/twilio/rails/phone/tree.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #digits? ⇒ Boolean
-
#initialize(args) ⇒ Gather
constructor
A new instance of Gather.
- #interrupt? ⇒ Boolean
- #speech? ⇒ Boolean
- #voice? ⇒ Boolean
Constructor Details
#initialize(args) ⇒ Gather
Returns a new instance of Gather.
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/twilio/rails/phone/tree.rb', line 90 def initialize(args) case args when Proc @proc = args when Hash @args = args.with_indifferent_access @type = @args.delete(:type)&.to_sym raise Twilio::Rails::Phone::InvalidTreeError, "gather :type must be :digits, :voice, or :speech but was #{@type.inspect}" unless [:digits, :voice, :speech].include?(@type) if digits? @args[:timeout] ||= 5 @args[:number] ||= 1 elsif voice? @args[:length] ||= 10 @args[:transcribe] = false unless @args.key?(:transcribe) @args[:profanity_filter] = false unless @args.key?(:profanity_filter) elsif speech? @args[:language] ||= "en-US" else raise Twilio::Rails::Phone::InvalidTreeError, "gather :type must be :digits, :voice, or :speech but was #{@type.inspect}" end else raise Twilio::Rails::Phone::InvalidTreeError, "cannot parse :gather from #{args.inspect}" end end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
88 89 90 |
# File 'lib/twilio/rails/phone/tree.rb', line 88 def args @args end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
88 89 90 |
# File 'lib/twilio/rails/phone/tree.rb', line 88 def type @type end |
Instance Method Details
#digits? ⇒ Boolean
117 118 119 |
# File 'lib/twilio/rails/phone/tree.rb', line 117 def digits? type == :digits end |
#interrupt? ⇒ Boolean
129 130 131 132 133 134 135 |
# File 'lib/twilio/rails/phone/tree.rb', line 129 def interrupt? if @args.key?(:interrupt) !!@args[:interrupt] else false end end |
#speech? ⇒ Boolean
125 126 127 |
# File 'lib/twilio/rails/phone/tree.rb', line 125 def speech? type == :speech end |
#voice? ⇒ Boolean
121 122 123 |
# File 'lib/twilio/rails/phone/tree.rb', line 121 def voice? type == :voice end |