Class: AlexaToolbox::DisplayDirectiveTemplate
- Inherits:
-
Object
- Object
- AlexaToolbox::DisplayDirectiveTemplate
- Defined in:
- lib/alexa_toolbox/display_directive_template.rb
Overview
Handles creating display directives in responses.
Instance Attribute Summary collapse
-
#back_button ⇒ Object
Returns the value of attribute back_button.
-
#background_image ⇒ Object
Returns the value of attribute background_image.
-
#list_items ⇒ Object
Returns the value of attribute list_items.
-
#text_content ⇒ Object
Returns the value of attribute text_content.
-
#title ⇒ Object
Returns the value of attribute title.
-
#token ⇒ Object
Returns the value of attribute token.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #add_image_object(image) ⇒ Object
- #add_item_to_list(token, image, text_content) ⇒ Object
- #add_title(title) ⇒ Object
- #build ⇒ Object
- #hide_back_button ⇒ Object
-
#initialize(type, token, title = nil, back_button = "VISIBLE") ⇒ DisplayDirectiveTemplate
constructor
A new instance of DisplayDirectiveTemplate.
- #set_token(token) ⇒ Object
- #show_back_button ⇒ Object
Constructor Details
#initialize(type, token, title = nil, back_button = "VISIBLE") ⇒ DisplayDirectiveTemplate
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/alexa_toolbox/display_directive_template.rb', line 10 def initialize(type,token,title = nil, = "VISIBLE") @type = type @token = token @back_button = @background_image = AlexaToolbox::DisplayDirectiveImage.new @title = title @text_content = AlexaToolbox::DisplayDirectiveTextContent.new @list_items = [] @image = nil end |
Instance Attribute Details
#back_button ⇒ Object
Returns the value of attribute back_button.
8 9 10 |
# File 'lib/alexa_toolbox/display_directive_template.rb', line 8 def @back_button end |
#background_image ⇒ Object
Returns the value of attribute background_image.
8 9 10 |
# File 'lib/alexa_toolbox/display_directive_template.rb', line 8 def background_image @background_image end |
#list_items ⇒ Object
Returns the value of attribute list_items.
8 9 10 |
# File 'lib/alexa_toolbox/display_directive_template.rb', line 8 def list_items @list_items end |
#text_content ⇒ Object
Returns the value of attribute text_content.
8 9 10 |
# File 'lib/alexa_toolbox/display_directive_template.rb', line 8 def text_content @text_content end |
#title ⇒ Object
Returns the value of attribute title.
8 9 10 |
# File 'lib/alexa_toolbox/display_directive_template.rb', line 8 def title @title end |
#token ⇒ Object
Returns the value of attribute token.
8 9 10 |
# File 'lib/alexa_toolbox/display_directive_template.rb', line 8 def token @token end |
#type ⇒ Object
Returns the value of attribute type.
8 9 10 |
# File 'lib/alexa_toolbox/display_directive_template.rb', line 8 def type @type end |
Instance Method Details
#add_image_object(image) ⇒ Object
37 38 39 |
# File 'lib/alexa_toolbox/display_directive_template.rb', line 37 def add_image_object(image) @image = image end |
#add_item_to_list(token, image, text_content) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/alexa_toolbox/display_directive_template.rb', line 41 def add_item_to_list(token,image,text_content) list_item = {} list_item[:token] = token if !token.nil? list_item[:image] = image.build if !image.nil? list_item[:textContent] = text_content.build if !text_content.nil? @list_items.push(list_item) end |
#add_title(title) ⇒ Object
33 34 35 |
# File 'lib/alexa_toolbox/display_directive_template.rb', line 33 def add_title(title) @title = title end |
#build ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/alexa_toolbox/display_directive_template.rb', line 49 def build template = { :type => @type, :token => @token, :backButton => @back_button } template[:backgroundImage] = @background_image.build if @background_image.valid? template[:title] = @title if !@title.nil? && @title.length > 0 template[:textContent] = @text_content.build if @text_content.valid? template[:image] = @image.build if !@image.nil? && ["ListTemplate1","ListTemplate2","ListTemplate3","BodyTemplate2","BodyTemplate3","BodyTemplate6"].include?(@type) template[:listItems] = @list_items if !@list_items.empty? template end |
#hide_back_button ⇒ Object
25 26 27 |
# File 'lib/alexa_toolbox/display_directive_template.rb', line 25 def @back_button = "HIDDEN" end |
#set_token(token) ⇒ Object
21 22 23 |
# File 'lib/alexa_toolbox/display_directive_template.rb', line 21 def set_token(token) @token = token end |
#show_back_button ⇒ Object
29 30 31 |
# File 'lib/alexa_toolbox/display_directive_template.rb', line 29 def @back_button = "VISIBLE" end |