Class: AlexaSkill::Registry
- Inherits:
-
Object
- Object
- AlexaSkill::Registry
- Defined in:
- lib/alexa-skill/registry.rb
Class Method Summary collapse
- .list ⇒ Object
- .register(name, intent) ⇒ Object
- .schema ⇒ Object
- .types ⇒ Object
- .utterances ⇒ Object
Class Method Details
.list ⇒ Object
10 11 12 |
# File 'lib/alexa-skill/registry.rb', line 10 def self.list INTENTS end |
.register(name, intent) ⇒ Object
6 7 8 |
# File 'lib/alexa-skill/registry.rb', line 6 def self.register(name, intent) INTENTS[name] = intent end |
.schema ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# 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 ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 |
# 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 |