Class: AlexaToolbox::DisplayDirective
- Inherits:
-
Object
- Object
- AlexaToolbox::DisplayDirective
- Defined in:
- lib/alexa_toolbox/display_directive.rb
Overview
Handles creating display directives in responses. developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/display-interface-reference
Instance Attribute Summary collapse
-
#template ⇒ Object
Returns the value of attribute template.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #build_directive(json = true) ⇒ Object
-
#initialize(template, token) ⇒ DisplayDirective
constructor
A new instance of DisplayDirective.
Constructor Details
#initialize(template, token) ⇒ DisplayDirective
Returns a new instance of DisplayDirective.
10 11 12 13 14 15 16 17 |
# File 'lib/alexa_toolbox/display_directive.rb', line 10 def initialize(template,token) @type = "Display.RenderTemplate" if ["BodyTemplate1","BodyTemplate2","BodyTemplate3","BodyTemplate6","ListTemplate1","ListTemplate2","ListTemplate3"].include?(template) @template = AlexaToolbox::DisplayDirectiveTemplate.new(template,token) else raise ArgumentError, 'Invalid display template given. Valid options are: "BodyTemplate1","BodyTemplate2","BodyTemplate3","BodyTemplate6","ListTemplate1","ListTemplate2","ListTemplate3"' end end |
Instance Attribute Details
#template ⇒ Object
Returns the value of attribute template.
8 9 10 |
# File 'lib/alexa_toolbox/display_directive.rb', line 8 def template @template end |
#type ⇒ Object
Returns the value of attribute type.
8 9 10 |
# File 'lib/alexa_toolbox/display_directive.rb', line 8 def type @type end |
Instance Method Details
#build_directive(json = true) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/alexa_toolbox/display_directive.rb', line 19 def build_directive(json = true) data_hash = { "type": @type, "template": @template.build } json ? JSON.parse(data_hash.to_json) : data_hash end |