Class: AlexaToolbox::DisplayDirectiveTextContent
- Inherits:
-
Object
- Object
- AlexaToolbox::DisplayDirectiveTextContent
- Defined in:
- lib/alexa_toolbox/display_directive_text_content.rb
Overview
Handles creating display directives in responses.
Instance Attribute Summary collapse
-
#text_content ⇒ Object
Returns the value of attribute text_content.
Instance Method Summary collapse
- #add_primary_text(text, type = "PlainText") ⇒ Object
- #add_secondary_text(text, type = "PlainText") ⇒ Object
- #add_tertiary_text(text, type = "PlainText") ⇒ Object
- #add_text(slot, text, type = "PlainText") ⇒ Object
- #build ⇒ Object
-
#initialize ⇒ DisplayDirectiveTextContent
constructor
A new instance of DisplayDirectiveTextContent.
- #valid? ⇒ Boolean
Constructor Details
#initialize ⇒ DisplayDirectiveTextContent
Returns a new instance of DisplayDirectiveTextContent.
8 9 10 |
# File 'lib/alexa_toolbox/display_directive_text_content.rb', line 8 def initialize @text_content = {} end |
Instance Attribute Details
#text_content ⇒ Object
Returns the value of attribute text_content.
6 7 8 |
# File 'lib/alexa_toolbox/display_directive_text_content.rb', line 6 def text_content @text_content end |
Instance Method Details
#add_primary_text(text, type = "PlainText") ⇒ Object
28 29 30 31 32 33 |
# File 'lib/alexa_toolbox/display_directive_text_content.rb', line 28 def add_primary_text(text,type = "PlainText") @text_content["primaryText"] = { text: text, type: type } end |
#add_secondary_text(text, type = "PlainText") ⇒ Object
35 36 37 38 39 40 |
# File 'lib/alexa_toolbox/display_directive_text_content.rb', line 35 def add_secondary_text(text,type = "PlainText") @text_content["secondaryText"] = { text: text, type: type } end |
#add_tertiary_text(text, type = "PlainText") ⇒ Object
42 43 44 45 46 47 |
# File 'lib/alexa_toolbox/display_directive_text_content.rb', line 42 def add_tertiary_text(text,type = "PlainText") @text_content["tertiaryText"] = { text: text, type: type } end |
#add_text(slot, text, type = "PlainText") ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/alexa_toolbox/display_directive_text_content.rb', line 12 def add_text(slot,text,type = "PlainText") if ["primary","tertiary","secondary"].include?(slot) @text_content[slot + "Text"] = { text: text, type: type } elsif ["primaryText","secondaryText","tertiaryText"].include?(slot) @text_content[slot] = { text: text, type: type } else raise ArgumentError, 'Invalid text type given. Valid options are: "primary","tertiary","secondary","primaryText","secondaryText","tertiaryText"' end end |
#build ⇒ Object
53 54 55 |
# File 'lib/alexa_toolbox/display_directive_text_content.rb', line 53 def build @text_content end |
#valid? ⇒ Boolean
49 50 51 |
# File 'lib/alexa_toolbox/display_directive_text_content.rb', line 49 def valid? @text_content != {} end |