class AlexaSkill::Registry
Public Class Methods
list()
click to toggle source
# File lib/alexa-skill/registry.rb, line 10 def self.list INTENTS end
register(name, intent)
click to toggle source
# File lib/alexa-skill/registry.rb, line 6 def self.register(name, intent) INTENTS[name] = intent end
schema()
click to toggle source
# File lib/alexa-skill/registry.rb, line 24 def self.schema response = {intents:[]} INTENTS.each do |name, intent| intent_schema = {intent: name, slots: []} intent.slots.each do |slot, properties| if properties.is_a?(String) slot_type = properties elsif properties.is_a?(Array) slot_type = "LIST_OF_#{slot.upcase}" else raise ArgumentError, "Property '#{properties}` not recognized" end intent_schema[:slots] << { name: slot, type: slot_type } end response[:intents] << intent_schema end response end
types()
click to toggle source
# File lib/alexa-skill/registry.rb, line 47 def self.types response = {} INTENTS.each do |name, intent| intent.slots.each do |slot, properties| if properties.is_a?(Array) slot_type = "LIST_OF_#{slot.upcase}" response[slot_type] = properties end end end response end
utterances()
click to toggle source
# File lib/alexa-skill/registry.rb, line 14 def self.utterances response = [] INTENTS.each do |name, intent| intent.utterances.each do |utter| response << "#{name} #{utter}" end end response end