Class: WitBot::Context

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#entitiesObject



14
15
16
# File 'lib/wit_bot/models/context.rb', line 14

def entities
  @entities ||= ContextEntities.new
end

#hash=(value) ⇒ Object (writeonly)

Sets the attribute hash

Parameters:

  • value

    the value to set the attribute hash to.



4
5
6
# File 'lib/wit_bot/models/context.rb', line 4

def hash=(value)
  @hash = value
end

#locationObject

Returns the value of attribute location.



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

def location
  @location
end

#reference_timeObject

Returns the value of attribute reference_time.



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

def reference_time
  @reference_time
end

#stateObject



6
7
8
# File 'lib/wit_bot/models/context.rb', line 6

def state
  @state ||= []
end

Instance Method Details

#as_jsonObject



18
19
20
21
22
23
24
25
# File 'lib/wit_bot/models/context.rb', line 18

def as_json
  h = {}
  h[:state] = state if state && !state.empty?
  h[:reference_time] = reference_time.iso8601 if reference_time
  h[:entities] = entities if @entities
  h[:location] = location if location
  h
end

#empty?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/wit_bot/models/context.rb', line 10

def empty?
  as_json.empty?
end