Class: Clova::Response
- Inherits:
-
Object
- Object
- Clova::Response
- Defined in:
- lib/clova-speech/response.rb
Instance Attribute Summary collapse
-
#card ⇒ Object
Returns the value of attribute card.
-
#default_language ⇒ Object
Returns the value of attribute default_language.
-
#directives ⇒ Object
Returns the value of attribute directives.
-
#output_speech ⇒ Object
Returns the value of attribute output_speech.
-
#reprompt_speech ⇒ Object
Returns the value of attribute reprompt_speech.
-
#session_attributes ⇒ Object
Returns the value of attribute session_attributes.
-
#should_end_session ⇒ Object
Returns the value of attribute should_end_session.
-
#type ⇒ Object
Returns the value of attribute type.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #add_reprompt(value, type: 'PlainText') ⇒ Object
- #add_session_attribute(key:, value:) ⇒ Object
-
#add_speech(value, type: 'PlainText', language: @default_language) ⇒ Object
type either is ‘PlainText’ or ‘URL’.
- #as_json ⇒ Object
-
#initialize ⇒ Response
constructor
A new instance of Response.
- #response ⇒ Object
Constructor Details
#initialize ⇒ Response
Returns a new instance of Response.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/clova-speech/response.rb', line 5 def initialize @default_language = 'ja' @version = Clova::VERSION @output_speech = OutputSpeech.new @session_attributes = {} @directives = [] @should_end_session = false @card = {} @reprompt_speech = OutputSpeech.new end |
Instance Attribute Details
#card ⇒ Object
Returns the value of attribute card.
3 4 5 |
# File 'lib/clova-speech/response.rb', line 3 def card @card end |
#default_language ⇒ Object
Returns the value of attribute default_language.
3 4 5 |
# File 'lib/clova-speech/response.rb', line 3 def default_language @default_language end |
#directives ⇒ Object
Returns the value of attribute directives.
3 4 5 |
# File 'lib/clova-speech/response.rb', line 3 def directives @directives end |
#output_speech ⇒ Object
Returns the value of attribute output_speech.
3 4 5 |
# File 'lib/clova-speech/response.rb', line 3 def output_speech @output_speech end |
#reprompt_speech ⇒ Object
Returns the value of attribute reprompt_speech.
3 4 5 |
# File 'lib/clova-speech/response.rb', line 3 def reprompt_speech @reprompt_speech end |
#session_attributes ⇒ Object
Returns the value of attribute session_attributes.
3 4 5 |
# File 'lib/clova-speech/response.rb', line 3 def session_attributes @session_attributes end |
#should_end_session ⇒ Object
Returns the value of attribute should_end_session.
3 4 5 |
# File 'lib/clova-speech/response.rb', line 3 def should_end_session @should_end_session end |
#type ⇒ Object
Returns the value of attribute type.
3 4 5 |
# File 'lib/clova-speech/response.rb', line 3 def type @type end |
#version ⇒ Object
Returns the value of attribute version.
3 4 5 |
# File 'lib/clova-speech/response.rb', line 3 def version @version end |
Instance Method Details
#add_reprompt(value, type: 'PlainText') ⇒ Object
33 34 35 |
# File 'lib/clova-speech/response.rb', line 33 def add_reprompt(value, type: 'PlainText') @reprompt_speech.add_speech(value: value, type: type) end |
#add_session_attribute(key:, value:) ⇒ Object
24 25 26 |
# File 'lib/clova-speech/response.rb', line 24 def add_session_attribute(key:, value:) @session_attributes[key] = value end |
#add_speech(value, type: 'PlainText', language: @default_language) ⇒ Object
type either is ‘PlainText’ or ‘URL’
29 30 31 |
# File 'lib/clova-speech/response.rb', line 29 def add_speech(value, type:'PlainText', language: @default_language) @output_speech.add_speech(value: value, type: type, language: language) end |
#as_json ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/clova-speech/response.rb', line 16 def as_json { version: version, sessionAttributes: session_attributes, response: response } end |
#response ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/clova-speech/response.rb', line 41 def response hash = { outputSpeech: output_speech.as_json, card: card, directives: directives, shouldEndSession: should_end_session } if !@reprompt_speech.empty? hash[:reprompt] = {outputSpeech: reprompt_speech.as_json} end hash end |