Class: AmazonEcho::Response
- Inherits:
-
Object
- Object
- AmazonEcho::Response
- Defined in:
- lib/amazon_echo/response.rb
Instance Method Summary collapse
-
#initialize(response: {}) ⇒ Response
constructor
A new instance of Response.
- #response ⇒ Object
- #response_card ⇒ Object
- #response_end_session ⇒ Object
- #response_hash ⇒ Object
- #response_output_speech ⇒ Object
- #response_reprompt ⇒ Object
- #say(output_speech = nil) ⇒ Object
- #session_attributes ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(response: {}) ⇒ Response
Returns a new instance of Response.
2 3 4 5 6 |
# File 'lib/amazon_echo/response.rb', line 2 def initialize(response: {}) @version = response[:version] @session_attributes = response[:session_attributes] @output_speech = 'OK, done' end |
Instance Method Details
#response ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/amazon_echo/response.rb', line 45 def response { 'version' => version, 'sessionAttributes' => session_attributes, 'response' => response_hash, } end |
#response_card ⇒ Object
33 34 35 |
# File 'lib/amazon_echo/response.rb', line 33 def response_card { 'type' => 'Simple', 'title' => 'Amazon Echo gem', 'content' => 'Response from amazon echo gem' } end |
#response_end_session ⇒ Object
41 42 43 |
# File 'lib/amazon_echo/response.rb', line 41 def response_end_session true end |
#response_hash ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/amazon_echo/response.rb', line 21 def response_hash { 'outputSpeech' => response_output_speech, 'card' => response_card, 'reprompt' => response_reprompt, 'shouldEndSession' => response_end_session } end |
#response_output_speech ⇒ Object
29 30 31 |
# File 'lib/amazon_echo/response.rb', line 29 def response_output_speech { 'type' => 'PlainText', 'text' => @output_speech } end |
#response_reprompt ⇒ Object
37 38 39 |
# File 'lib/amazon_echo/response.rb', line 37 def response_reprompt { 'outputSpeech' => { 'type' => 'PlainText', 'text' => 'Try again' }} end |
#say(output_speech = nil) ⇒ Object
8 9 10 11 |
# File 'lib/amazon_echo/response.rb', line 8 def say(output_speech=nil) @output_speech = output_speech if output_speech response end |
#session_attributes ⇒ Object
17 18 19 |
# File 'lib/amazon_echo/response.rb', line 17 def session_attributes {} || @session_attributes end |
#version ⇒ Object
13 14 15 |
# File 'lib/amazon_echo/response.rb', line 13 def version '1.0' || @version end |