Class: Wit::REST::MultiIntent

Inherits:
Result
  • Object
show all
Defined in:
lib/wit_ruby/rest/intent.rb

Overview

MultiIntent wraps around results that are an array with intents.

Instance Method Summary collapse

Methods inherited from Result

#empty?, #entities, #method_missing, #raw_data, #refreshable?, #restBody, #restCode, #restPath

Constructor Details

#initialize(resultData, requestRest = nil, requestPath = nil, requestBody = nil) ⇒ Wit::REST::MultiIntent

Generates instance variable that holds intents as Wit::REST::Result.

Parameters:

  • resultData (Hash)

    data from the call.

  • requestRest (String) (defaults to: nil)

    rest code for the call.

  • requestPath (String) (defaults to: nil)

    request path for the call.

  • requestBody (Hash) (defaults to: nil)

    body of the call.



66
67
68
69
70
71
72
# File 'lib/wit_ruby/rest/intent.rb', line 66

def initialize(resultData, requestRest=nil, requestPath=nil, requestBody=nil)
  ## Pass in empty hash to default to method missing for everything not defined here.
  super({}, requestRest, requestPath, requestBody)
  @intents = resultData.map do |intent|
    Result.new(intent)
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Wit::REST::Result

Instance Method Details

#[](num) ⇒ Wit::REST::Result

Overide that assists in calling the proper index in the array of intent results.

Parameters:

  • num (Integer)

    index of the array of Wit::REST::Result.

Returns:



78
79
80
# File 'lib/wit_ruby/rest/intent.rb', line 78

def [](num)
  @intents[num]
end

#eachWit::REST::Result

Assists in going through each intent in the instance variable.

Returns:



85
86
87
88
89
# File 'lib/wit_ruby/rest/intent.rb', line 85

def each
  @intents.each do |intent|
    lambda{intent}
  end
end