Class: AlexaGenerator::Intent::Builder
- Inherits:
-
Object
- Object
- AlexaGenerator::Intent::Builder
- Defined in:
- lib/alexa_generator/intent.rb
Instance Attribute Summary collapse
-
#bindings ⇒ Object
readonly
Returns the value of attribute bindings.
-
#utterance_templates ⇒ Object
readonly
Returns the value of attribute utterance_templates.
Instance Method Summary collapse
- #add_slot(name, type, &block) ⇒ Object
- #add_utterance_template(template) ⇒ Object
- #add_utterance_templates(*templates) ⇒ Object
- #create ⇒ Object
-
#initialize(name) ⇒ Builder
constructor
A new instance of Builder.
Constructor Details
#initialize(name) ⇒ Builder
Returns a new instance of Builder.
36 37 38 39 40 41 |
# File 'lib/alexa_generator/intent.rb', line 36 def initialize(name) @name = name @slots = [] @bindings = [] @utterance_templates = [] end |
Instance Attribute Details
#bindings ⇒ Object (readonly)
Returns the value of attribute bindings.
34 35 36 |
# File 'lib/alexa_generator/intent.rb', line 34 def bindings @bindings end |
#utterance_templates ⇒ Object (readonly)
Returns the value of attribute utterance_templates.
34 35 36 |
# File 'lib/alexa_generator/intent.rb', line 34 def utterance_templates @utterance_templates end |
Instance Method Details
#add_slot(name, type, &block) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/alexa_generator/intent.rb', line 43 def add_slot(name, type, &block) if AmazonIntentType.amazon_intent?(@name) raise AlexaGenerator::InvalidIntentError, "Amazon intents don't support slots. Tried to add a slot to intent of type: #{type}" end builder = Slot.build(name, type, &block) slot_bindings = builder.bindings.map { |x| SlotBinding.new(name, x) } @bindings.concat(slot_bindings) @slots.push(builder.create) end |
#add_utterance_template(template) ⇒ Object
57 58 59 |
# File 'lib/alexa_generator/intent.rb', line 57 def add_utterance_template(template) add_utterance_templates(template) end |
#add_utterance_templates(*templates) ⇒ Object
61 62 63 |
# File 'lib/alexa_generator/intent.rb', line 61 def add_utterance_templates(*templates) templates.each { |x| @utterance_templates.push(SampleUtteranceTemplate.new(@name, x)) } end |