class AlexaToolbox::DisplayDirectiveTextContent

Handles creating display directives in responses.

Attributes

text_content[RW]

Public Class Methods

new() click to toggle source
# File lib/alexa_toolbox/display_directive_text_content.rb, line 8
def initialize
  @text_content = {}
end

Public Instance Methods

add_primary_text(text,type = "PlainText") click to toggle source
# 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") click to toggle source
# 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") click to toggle source
# 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") click to toggle source
# 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() click to toggle source
# File lib/alexa_toolbox/display_directive_text_content.rb, line 53
def build
  @text_content
end
valid?() click to toggle source
# File lib/alexa_toolbox/display_directive_text_content.rb, line 49
def valid?
  @text_content != {}
end