Class: AlexaSkill::IntentBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/alexa-skill/intent_builder.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ IntentBuilder

Returns a new instance of IntentBuilder.



6
7
8
9
10
# File 'lib/alexa-skill/intent_builder.rb', line 6

def initialize(&block)
  @slots = {}
  @utterances = []
  self.instance_eval(&block)
end

Instance Attribute Details

#card_responseObject (readonly)

Returns the value of attribute card_response.



5
6
7
# File 'lib/alexa-skill/intent_builder.rb', line 5

def card_response
  @card_response
end

#responseObject (readonly)

Returns the value of attribute response.



5
6
7
# File 'lib/alexa-skill/intent_builder.rb', line 5

def response
  @response
end

#slotsObject (readonly)

Returns the value of attribute slots.



5
6
7
# File 'lib/alexa-skill/intent_builder.rb', line 5

def slots
  @slots
end

#utterancesObject (readonly)

Returns the value of attribute utterances.



5
6
7
# File 'lib/alexa-skill/intent_builder.rb', line 5

def utterances
  @utterances
end

Class Method Details

.build(builder) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/alexa-skill/intent_builder.rb', line 28

def self.build(builder)
  intent = AlexaSkill::Intent.new
  intent.slots      = builder.slots
  intent.utterances = builder.utterances
  intent.response   = builder.response
  intent.card       = builder.card_response
  intent
end

Instance Method Details

#card(&block) ⇒ Object



16
17
18
# File 'lib/alexa-skill/intent_builder.rb', line 16

def card(&block)
  @card_response = block
end

#respond(&block) ⇒ Object



20
21
22
# File 'lib/alexa-skill/intent_builder.rb', line 20

def respond(&block)
  @response = block
end

#slot(name, options = []) ⇒ Object



12
13
14
# File 'lib/alexa-skill/intent_builder.rb', line 12

def slot(name, options=[])
  @slots[name] = options
end

#utterance(value) ⇒ Object



24
25
26
# File 'lib/alexa-skill/intent_builder.rb', line 24

def utterance(value)
  @utterances << value
end