Class: WitBot::EntityModel

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entity, role, raw) ⇒ EntityModel

Returns a new instance of EntityModel.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/wit_bot/models/wit/entity/entity_model.rb', line 6

def initialize(entity, role, raw)
  @entity = entity
  @role = role
  @raw = raw.with_indifferent_access

  @value = case @raw[:type].to_sym
           when :value
             @raw[:value].to_s
           else
             @raw[:value]
           end

  @others = []
end

Instance Attribute Details

#entityObject (readonly)

Returns the value of attribute entity.



4
5
6
# File 'lib/wit_bot/models/wit/entity/entity_model.rb', line 4

def entity
  @entity
end

#othersObject

Returns the value of attribute others.



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

def others
  @others
end

#rawObject (readonly)

Returns the value of attribute raw.



4
5
6
# File 'lib/wit_bot/models/wit/entity/entity_model.rb', line 4

def raw
  @raw
end

#roleObject (readonly)

Returns the value of attribute role.



4
5
6
# File 'lib/wit_bot/models/wit/entity/entity_model.rb', line 4

def role
  @role
end

#valueObject (readonly)

Returns the value of attribute value.



4
5
6
# File 'lib/wit_bot/models/wit/entity/entity_model.rb', line 4

def value
  @value
end

Instance Method Details

#to_sObject



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

def to_s
  value.to_s
end