Class: Twilio::Rails::Phone::Tree::Message
- Inherits:
-
Object
- Object
- Twilio::Rails::Phone::Tree::Message
- Defined in:
- lib/twilio/rails/phone/tree.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
-
#voice ⇒ Object
readonly
Returns the value of attribute voice.
Instance Method Summary collapse
-
#initialize(say: nil, play: nil, pause: nil, voice: nil, &block) ⇒ Message
constructor
A new instance of Message.
- #pause? ⇒ Boolean
- #play? ⇒ Boolean
- #say? ⇒ Boolean
Constructor Details
#initialize(say: nil, play: nil, pause: nil, voice: nil, &block) ⇒ Message
Returns a new instance of Message.
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/twilio/rails/phone/tree.rb', line 141 def initialize(say: nil, play: nil, pause: nil, voice: nil, &block) @say = say.presence @play = play.presence @pause = pause.presence.to_i @pause = nil if @pause == 0 @voice = voice.presence @block = block if block_given? raise Twilio::Rails::Phone::InvalidTreeError, "must only have one of say: play: pause:" if (@say && @play) || (@say && @pause) || (@play && @pause) raise Twilio::Rails::Phone::InvalidTreeError, "say: must be a string or proc" if @say && !(@say.is_a?(String) || @say.is_a?(Proc)) raise Twilio::Rails::Phone::InvalidTreeError, "play: must be a string or proc" if @play && !(@play.is_a?(String) || @play.is_a?(Proc)) raise Twilio::Rails::Phone::InvalidTreeError, "play: be a valid url but is #{ @play }" if @play && @play.is_a?(String) && !@play.match(/^https?:\/\/.+/) raise Twilio::Rails::Phone::InvalidTreeError, "pause: must be over zero but is #{ @pause }" if @pause && @pause <= 0 raise Twilio::Rails::Phone::InvalidTreeError, "block is only valid for say:" if block_given? && (@play || @pause) end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
139 140 141 |
# File 'lib/twilio/rails/phone/tree.rb', line 139 def block @block end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
139 140 141 |
# File 'lib/twilio/rails/phone/tree.rb', line 139 def value @value end |
#voice ⇒ Object (readonly)
Returns the value of attribute voice.
139 140 141 |
# File 'lib/twilio/rails/phone/tree.rb', line 139 def voice @voice end |
Instance Method Details
#pause? ⇒ Boolean
165 166 167 |
# File 'lib/twilio/rails/phone/tree.rb', line 165 def pause? !!@pause end |
#play? ⇒ Boolean
161 162 163 |
# File 'lib/twilio/rails/phone/tree.rb', line 161 def play? !!@play end |
#say? ⇒ Boolean
157 158 159 |
# File 'lib/twilio/rails/phone/tree.rb', line 157 def say? !!(@say || @block) end |