class AmazonEcho
Attributes
app_id[R]
intent[R]
res[RW]
response[RW]
session_attributes[RW]
session_new[R]
slots[R]
Public Class Methods
intention_selector(alexa)
click to toggle source
def session
self.session_attributes[:session]
end
# File lib/amazonecho.rb, line 19 def self.intention_selector(alexa) Responsible.slots_passer(alexa) end
new(args={})
click to toggle source
# File lib/amazonecho.rb, line 5 def initialize(args={}) @app_id = Initializable.app_id(args) @session_new = Initializable.session_new(args) @intent = Initializable.parse_intent(args) @slots = Initializable.slots(args) @res = Initializable.build_response(args) @session_attributes = Initializable.session_attributes(args) end
verify?(id)
click to toggle source
# File lib/amazonecho.rb, line 23 def self.verify?(id) id == ENV['APP_ID'] end
Public Instance Methods
card(type, args={})
click to toggle source
# File lib/amazonecho.rb, line 51 def card(type, args={}) card = Cardable.new(type,args) @res[:response][:card] = card.build_response end
end_session(boolean)
click to toggle source
private
# File lib/amazonecho.rb, line 59 def end_session(boolean) self.res[:response][:shouldEndSession] = boolean end
question(text)
click to toggle source
# File lib/amazonecho.rb, line 33 def question(text) self.text(text) self.end_session(false) self.set_session self end
reprompt(text)
click to toggle source
# File lib/amazonecho.rb, line 40 def reprompt(text) if Responsible.ssml?(text) @res[:response][:reprompt] = {outputSpeech: {type: "SSML", ssml: text}} else @res[:response][:reprompt] = {outputSpeech: {type: "PlainText", text: text}} end self end
set_session()
click to toggle source
# File lib/amazonecho.rb, line 72 def set_session self.session_attributes.each do |key,value| @res[:sessionAttributes][:session][key] = value end end
statement(text)
click to toggle source
# File lib/amazonecho.rb, line 27 def statement(text) self.text(text) self.end_session(true) self end
text(text)
click to toggle source
# File lib/amazonecho.rb, line 63 def text(text) if Responsible.ssml?(text) @res[:response][:outputSpeech] = {type: "SSML", ssml: text} else @res[:response][:outputSpeech] = {type: "PlainText", text: text} end self end