class AlexaRuby::Slot

Class that encapsulates each slot

Attributes

confirmation_status[RW]
name[RW]
value[RW]

Public Class Methods

new(slot) click to toggle source

Initialize slot and define its name and value

@param slot [Hash] slot parameters

# File lib/alexa_ruby/request/intent_request/slot.rb, line 9
def initialize(slot)
  @slot = slot
  raise ArgumentError, 'Missing slot parameters' if invalid_slot?
  @name = @slot[:name]
  @value = @slot[:value]
  @confirmation_status = define_confirmation_status
end

Private Instance Methods

define_confirmation_status() click to toggle source

Define user confirmation status

@return [Symbol] current confirmation status

# File lib/alexa_ruby/request/intent_request/slot.rb, line 29
def define_confirmation_status
  case @slot[:confirmationStatus]
  when 'NONE'
    :unknown
  when 'CONFIRMED'
    :confirmed
  when 'DENIED'
    :denied
  end
end
invalid_slot?() click to toggle source

Check if it is a valid slot or not

@return [Boolean]

# File lib/alexa_ruby/request/intent_request/slot.rb, line 22
def invalid_slot?
  @slot[:name].nil?
end