Class: Ralyxa::Skill

Inherits:
Object
  • Object
show all
Defined in:
lib/ralyxa/skill.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request) ⇒ Skill

Returns a new instance of Skill.



9
10
11
# File 'lib/ralyxa/skill.rb', line 9

def initialize(request)
  @request = request
end

Class Method Details

.handle(request, alexa_request_wrapper = Ralyxa::RequestEntities::Request) ⇒ Object



25
26
27
# File 'lib/ralyxa/skill.rb', line 25

def handle(request, alexa_request_wrapper = Ralyxa::RequestEntities::Request)
  new(alexa_request_wrapper.new(request)).handle
end

.handlersObject



29
30
31
# File 'lib/ralyxa/skill.rb', line 29

def handlers
  @handlers.dup
end

.intent(intent_name, handler_base_class = Ralyxa::Handler, &intent_block) ⇒ Object



19
20
21
22
23
# 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

Instance Method Details

#handleObject



13
14
15
16
# 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