Class: WitBot::ContextEntities
- Inherits:
-
Object
- Object
- WitBot::ContextEntities
- Defined in:
- lib/wit_bot/models/context_entities.rb
Instance Method Summary collapse
- #[](entity) ⇒ Object
- #[]=(entity, value, expressions = [value]) ⇒ Object
- #as_json ⇒ Object
-
#initialize ⇒ ContextEntities
constructor
A new instance of ContextEntities.
Constructor Details
#initialize ⇒ ContextEntities
Returns a new instance of ContextEntities.
3 4 5 |
# File 'lib/wit_bot/models/context_entities.rb', line 3 def initialize @hash = {} end |
Instance Method Details
#[](entity) ⇒ Object
6 7 8 |
# File 'lib/wit_bot/models/context_entities.rb', line 6 def [](entity) @hash[entity] end |
#[]=(entity, value, expressions = [value]) ⇒ Object
9 10 11 |
# File 'lib/wit_bot/models/context_entities.rb', line 9 def []=(entity, value, expressions=[value]) @hash[entity] = value.is_a?(EntityValue) ? value : EntityValue.new(value, expressions) end |
#as_json ⇒ Object
12 13 14 15 16 |
# File 'lib/wit_bot/models/context_entities.rb', line 12 def as_json @hash.map do |id, values| {id: id, values: values} end end |