class AlexaToolbox::DisplayDirectiveTemplate

Handles creating display directives in responses.

Attributes

back_button[RW]
background_image[RW]
list_items[RW]
text_content[RW]
title[RW]
token[RW]
type[RW]

Public Class Methods

new(type,token,title = nil,back_button = "VISIBLE") click to toggle source
# File lib/alexa_toolbox/display_directive_template.rb, line 10
def initialize(type,token,title = nil,back_button = "VISIBLE")
  @type = type
  @token = token
  @back_button = back_button
  @background_image = AlexaToolbox::DisplayDirectiveImage.new
  @title = title
  @text_content = AlexaToolbox::DisplayDirectiveTextContent.new
  @list_items = []
  @image = nil
end

Public Instance Methods

add_image_object(image) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# File lib/alexa_toolbox/display_directive_template.rb, line 33
def add_title(title)
  @title = title
end
build() click to toggle source
# 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() click to toggle source
# File lib/alexa_toolbox/display_directive_template.rb, line 25
def hide_back_button
  @back_button = "HIDDEN"
end
set_token(token) click to toggle source
# File lib/alexa_toolbox/display_directive_template.rb, line 21
def set_token(token)
  @token = token
end
show_back_button() click to toggle source
# File lib/alexa_toolbox/display_directive_template.rb, line 29
def show_back_button
  @back_button = "VISIBLE"
end