Class: WitBot::WitModel::Intent

Inherits:
Base
  • Object
show all
Defined in:
lib/wit_bot/models/wit/intent.rb

Constant Summary collapse

@@intents =
{}

Instance Attribute Summary

Attributes inherited from Base

#id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

all, #create, #delete, #from_response_data, get, #get, #on_delete, #to_h

Constructor Details

#initialize(id, doc: nil, metadata: nil, expressions: [], states: [], meta: {states: []}, request: false) ⇒ Intent

Returns a new instance of Intent.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/wit_bot/models/wit/intent.rb', line 10

def initialize(id, doc: nil, metadata: nil, expressions: [], states: [], meta: {states: []}, request: false)
  super

  @name = id
  @doc = doc
  @metadata = 

  meta[:states].concat states

  @expressions = process_expressions expressions
  @meta = process_meta meta

  @@intents[@name] = self
end

Class Method Details

.find(name) ⇒ Object



25
26
27
# File 'lib/wit_bot/models/wit/intent.rb', line 25

def self.find(name)
  @@intents[name] || self.new(name, request: true)
end

Instance Method Details

#==(other) ⇒ Object



29
30
31
# File 'lib/wit_bot/models/wit/intent.rb', line 29

def ==(other)
  self.name == other.name
end