class Ralyxa::Skill
Public Class Methods
handle(request, alexa_request_wrapper = Ralyxa::RequestEntities::Request)
click to toggle source
# File lib/ralyxa/skill.rb, line 25 def handle(request, alexa_request_wrapper = Ralyxa::RequestEntities::Request) new(alexa_request_wrapper.new(request)).handle end
handlers()
click to toggle source
# File lib/ralyxa/skill.rb, line 29 def handlers @handlers.dup end
intent(intent_name, handler_base_class = Ralyxa::Handler, &intent_block)
click to toggle source
# File lib/ralyxa/skill.rb, line 19 def intent(intent_name, handler_base_class = Ralyxa::Handler, &intent_block) intent_handler = Class.new(handler_base_class) intent_handler.send(:define_method, :handle, &intent_block) @handlers[intent_name] = intent_handler end
new(request)
click to toggle source
# File lib/ralyxa/skill.rb, line 9 def initialize(request) @request = request end
Public Instance Methods
handle()
click to toggle source
# File lib/ralyxa/skill.rb, line 13 def handle handler = self.class.handlers[@request.intent_name] handler ? handler.new(@request).handle : warn(handler_not_found) end
Private Instance Methods
handler_not_found()
click to toggle source
# File lib/ralyxa/skill.rb, line 36 def handler_not_found <<~HEREDOC \e[33m WARNING: An intent declaration for intent "#{@request.intent_name}" was not found. To define it, add an intent declaration inside a directory called 'intents', on the same directory level as the runfile for your server application. You probably want something like: intent "#{@request.intent_name}" do respond("Hello World!") end \e[0m HEREDOC end