Class: WitBot::Expression

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(intent, body, request: false) ⇒ Expression

Returns a new instance of Expression.



5
6
7
8
9
# File 'lib/wit_bot/models/wit/expression.rb', line 5

def initialize(intent, body, request: false)
  @intent = intent
  @body = body.is_a?(Hash) ? body.with_indifferent_access[:body] : body
  create if request
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



3
4
5
# File 'lib/wit_bot/models/wit/expression.rb', line 3

def body
  @body
end

#intentObject

Returns the value of attribute intent.



3
4
5
# File 'lib/wit_bot/models/wit/expression.rb', line 3

def intent
  @intent
end

Instance Method Details

#createObject



11
12
13
14
# File 'lib/wit_bot/models/wit/expression.rb', line 11

def create
  request.create
  intent.get
end

#deleteObject



16
17
18
19
# File 'lib/wit_bot/models/wit/expression.rb', line 16

def delete
  request.delete
  intent.get
end

#to_hObject Also known as: as_json



21
22
23
# File 'lib/wit_bot/models/wit/expression.rb', line 21

def to_h
  {body: body}
end