class Alexa::Slot
Attributes
name[RW]
value[RW]
Public Class Methods
new(attributes={})
click to toggle source
# File lib/alexa/slot.rb, line 5 def initialize(attributes={}) @name = attributes['name'] @value = attributes['value'] @resolutions = attributes['resolutions'] end
Public Instance Methods
as_json(options={})
click to toggle source
# File lib/alexa/slot.rb, line 42 def as_json(options={}) h = { name: name } # add other attributes only if they are present h.merge!(value: value) if value.present? h.merge!(resolutions: @resolutions) if @resolutions.present? h end
bad_match?()
click to toggle source
# File lib/alexa/slot.rb, line 28 def bad_match? return false if !has_resolutions? resolution["status"]["code"] == "ER_SUCCESS_NO_MATCH" end
has_resolutions?()
click to toggle source
# File lib/alexa/slot.rb, line 33 def has_resolutions? @resolutions.present? end
matched?()
click to toggle source
# File lib/alexa/slot.rb, line 23 def matched? return false if !has_resolutions? resolution["status"]["code"] == "ER_SUCCESS_MATCH" end
matched_id()
click to toggle source
# File lib/alexa/slot.rb, line 17 def matched_id if matched? resolution["values"].first["value"]["id"] end end
matched_value()
click to toggle source
# File lib/alexa/slot.rb, line 11 def matched_value if matched? resolution["values"].first["value"]["name"] end end
resolution()
click to toggle source
# File lib/alexa/slot.rb, line 37 def resolution return nil if !has_resolutions? @resolutions["resolutionsPerAuthority"].first end