Class: Voice::Actions::Talk
- Inherits:
-
Object
- Object
- Voice::Actions::Talk
- Defined in:
- lib/vonage/voice/actions/talk.rb
Instance Attribute Summary collapse
-
#bargeIn ⇒ Object
Returns the value of attribute bargeIn.
-
#language ⇒ Object
Returns the value of attribute language.
-
#level ⇒ Object
Returns the value of attribute level.
-
#loop ⇒ Object
Returns the value of attribute loop.
-
#premium ⇒ Object
Returns the value of attribute premium.
-
#style ⇒ Object
Returns the value of attribute style.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
- #action ⇒ Object
- #after_initialize! ⇒ Object
- #create_talk!(builder) ⇒ Object
-
#initialize(attributes = {}) ⇒ Talk
constructor
A new instance of Talk.
- #verify_barge_in ⇒ Object
- #verify_level ⇒ Object
- #verify_loop ⇒ Object
- #verify_premium ⇒ Object
- #verify_style ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Talk
Returns a new instance of Talk.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/vonage/voice/actions/talk.rb', line 7 def initialize(attributes= {}) @text = attributes.fetch(:text) @bargeIn = attributes.fetch(:bargeIn, nil) @loop = attributes.fetch(:loop, nil) @level = attributes.fetch(:level, nil) @language = attributes.fetch(:language, nil) @style = attributes.fetch(:style, nil) @premium = attributes.fetch(:premium, nil) after_initialize! end |
Instance Attribute Details
#bargeIn ⇒ Object
Returns the value of attribute bargeIn.
5 6 7 |
# File 'lib/vonage/voice/actions/talk.rb', line 5 def @bargeIn end |
#language ⇒ Object
Returns the value of attribute language.
5 6 7 |
# File 'lib/vonage/voice/actions/talk.rb', line 5 def language @language end |
#level ⇒ Object
Returns the value of attribute level.
5 6 7 |
# File 'lib/vonage/voice/actions/talk.rb', line 5 def level @level end |
#loop ⇒ Object
Returns the value of attribute loop.
5 6 7 |
# File 'lib/vonage/voice/actions/talk.rb', line 5 def loop @loop end |
#premium ⇒ Object
Returns the value of attribute premium.
5 6 7 |
# File 'lib/vonage/voice/actions/talk.rb', line 5 def premium @premium end |
#style ⇒ Object
Returns the value of attribute style.
5 6 7 |
# File 'lib/vonage/voice/actions/talk.rb', line 5 def style @style end |
#text ⇒ Object
Returns the value of attribute text.
5 6 7 |
# File 'lib/vonage/voice/actions/talk.rb', line 5 def text @text end |
Instance Method Details
#action ⇒ Object
61 62 63 |
# File 'lib/vonage/voice/actions/talk.rb', line 61 def action create_talk!(self) end |
#after_initialize! ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/vonage/voice/actions/talk.rb', line 19 def after_initialize! if self. end if self.loop verify_loop end if self.level verify_level end if self.style verify_style end if self.premium verify_premium end end |
#create_talk!(builder) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/vonage/voice/actions/talk.rb', line 65 def create_talk!(builder) ncco = [ { action: 'talk', text: builder.text } ] ncco[0].merge!(bargeIn: builder.) if (builder. || builder. == false) ncco[0].merge!(loop: builder.loop) if builder.loop ncco[0].merge!(level: builder.level) if builder.level ncco[0].merge!(language: builder.language) if builder.language ncco[0].merge!(style: builder.style) if builder.style ncco end |
#verify_barge_in ⇒ Object
41 42 43 |
# File 'lib/vonage/voice/actions/talk.rb', line 41 def raise ClientError.new("Expected 'bargeIn' value to be a Boolean") unless self. == true || self. == false end |
#verify_level ⇒ Object
49 50 51 |
# File 'lib/vonage/voice/actions/talk.rb', line 49 def verify_level raise ClientError.new("Expected 'level' value to be a number between -1 and 1") unless self.level.between?(-1, 1) end |
#verify_loop ⇒ Object
45 46 47 |
# File 'lib/vonage/voice/actions/talk.rb', line 45 def verify_loop raise ClientError.new("Expected 'loop' value to be either 1 or 0") unless self.loop == 1 || self.loop == 0 end |
#verify_premium ⇒ Object
57 58 59 |
# File 'lib/vonage/voice/actions/talk.rb', line 57 def verify_premium raise ClientError.new("Expected 'premium' value to be a Boolean") unless self.premium == true || self.premium == false end |
#verify_style ⇒ Object
53 54 55 |
# File 'lib/vonage/voice/actions/talk.rb', line 53 def verify_style raise ClientError.new("Expected 'style' value to be an Integer") unless self.style.is_a?(Integer) end |