Class: AskIO

Inherits:
Object
  • Object
show all
Defined in:
lib/askio.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(manifest, model, debug: false, userid: nil, deviceid: nil, appid: nil) ⇒ AskIO

Returns a new instance of AskIO.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/askio.rb', line 14

def initialize(manifest, model, debug: false, userid: nil, 
               deviceid: nil, appid: nil)

  @debug, @userid, @deviceid, @appid = debug, userid, deviceid, appid

  @locale = manifest['manifest']['publishingInformation']['locales']\
      .keys.first
  puts '@locale: ' + @locale.inspect if @debug
  
  @invocation = model['interactionModel']['languageModel']['invocationName']
  
  @utterances = model['interactionModel']['languageModel']\
                                      ['intents'].inject({}) do |r, intent|
    intent['samples'].each {|x| r[x.downcase] = intent['name']}
    r
  end

  puts '  debugger::@utterances: ' + @utterances.inspect if @debug

  @endpoint = manifest['manifest']['apis']['custom']['endpoint']['uri']

  puts '  debugger: @endpoint: ' + @endpoint.inspect if @debug
  
end

Instance Attribute Details

#invocationObject (readonly)

Returns the value of attribute invocation.



12
13
14
# File 'lib/askio.rb', line 12

def invocation
  @invocation
end

#utterancesObject (readonly)

Returns the value of attribute utterances.



12
13
14
# File 'lib/askio.rb', line 12

def utterances
  @utterances
end

Instance Method Details

#ask(request) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/askio.rb', line 39

def ask(request)
  
          
  r = @utterances[request]
  puts '  debugger: r: ' + r.inspect if @debug
  puts

  if r then

    puts '  debugger: your intent is to ' + r if @debug

    respond(r)      

  end        
          
end