Class: WitBot::Context
- Inherits:
-
Object
- Object
- WitBot::Context
- Defined in:
- lib/wit_bot/models/context.rb
Instance Attribute Summary collapse
- #entities ⇒ Object
-
#hash ⇒ Object
writeonly
Sets the attribute hash.
-
#location ⇒ Object
Returns the value of attribute location.
-
#reference_time ⇒ Object
Returns the value of attribute reference_time.
- #state ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#entities ⇒ Object
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
4 5 6 |
# File 'lib/wit_bot/models/context.rb', line 4 def hash=(value) @hash = value end |
#location ⇒ Object
Returns the value of attribute location.
3 4 5 |
# File 'lib/wit_bot/models/context.rb', line 3 def location @location end |
#reference_time ⇒ Object
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 |
#state ⇒ Object
6 7 8 |
# File 'lib/wit_bot/models/context.rb', line 6 def state @state ||= [] end |
Instance Method Details
#as_json ⇒ Object
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
10 11 12 |
# File 'lib/wit_bot/models/context.rb', line 10 def empty? as_json.empty? end |