Class: NluAdapter::Adapters::WatsonAssistant::Intent

Inherits:
Object
  • Object
show all
Includes:
NluAdapterIntent
Defined in:
lib/nlu_adapter/watson_assistant.rb

Overview

Class represents Intent in an IntentCollection

Instance Attribute Summary collapse

Attributes included from NluAdapterIntent

#name, #utterences

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Intent

Constructor



130
131
132
133
134
135
# File 'lib/nlu_adapter/watson_assistant.rb', line 130

def initialize(options = {})
	@id = options[:id] #check for is update
	@name = options[:name]
	@description = options[:description]
	@utterences = options[:utterences]
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



127
128
129
# File 'lib/nlu_adapter/watson_assistant.rb', line 127

def description
  @description
end

#idObject

Returns the value of attribute id.



127
128
129
# File 'lib/nlu_adapter/watson_assistant.rb', line 127

def id
  @id
end

Instance Method Details

#to_hHash

Convert self to Hash

Returns:

  • (Hash)

    ruby hash



140
141
142
143
144
145
146
# File 'lib/nlu_adapter/watson_assistant.rb', line 140

def to_h
	{
		name: @name,
		description: @description,
		examples: @utterences.map {|u| {"text" => u } }
	}
end

#to_jsonjson

convert self to json

Returns:

  • (json)

    json



151
152
153
# File 'lib/nlu_adapter/watson_assistant.rb', line 151

def to_json
	to_h.to_json
end