Sha256: 5539d2600ffa1a118dfaa6cc338143b4b4d64bf10c3201e4e94bf74a4cc9cd4d
Contents?: true
Size: 1.3 KB
Versions: 4
Compression:
Stored size: 1.3 KB
Contents
require_relative './output_speech' module Ralyxa class Response def initialize(output_speech, session_attributes, end_session, start_over, card) @output_speech = output_speech @session_attributes = session_attributes @end_session = end_session @start_over = start_over @card = card end def to_h Hash.new.tap do |response| set_version(response) set_session_attributes(response) set_response(response) end end def self.as_hash(output_speech: Ralyxa::OutputSpeech.as_hash, session_attributes: {}, end_session: false, start_over: false, card: false) new(output_speech, session_attributes, end_session, start_over, card).to_h end private attr_reader :response def set_version(response) response[:version] = "1.0" end def set_session_attributes(response) return response[:sessionAttributes] = {} if @start_over response[:sessionAttributes] = @session_attributes unless @session_attributes.empty? end def set_response(response) response[:response] = Hash.new response[:response][:outputSpeech] = @output_speech response[:response][:card] = @card if @card response[:response][:shouldEndSession] = @end_session end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
ralyxa-1.5.0 | lib/ralyxa/response.rb |
ralyxa-1.4.0 | lib/ralyxa/response.rb |
ralyxa-1.3.0 | lib/ralyxa/response.rb |
ralyxa-1.2.0 | lib/ralyxa/response.rb |