Class: Wit::Result

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Result

Returns a new instance of Result.



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/wit/wit.rb', line 38

def initialize(hash)
  @raw = hash
  @msg_id = hash['msg_id']
  @msg_body = hash['msg_body']
  @intent = hash['outcome']['intent']
  @confidence = hash['outcome']['confidence']
  @entities = EntityCollection.new
  hash['outcome']['entities'].each do |name, entity|
    @entities.send(:"#{name}=", Entity.new(entity))
  end
end

Instance Attribute Details

#confidenceObject (readonly)

Returns the value of attribute confidence.



36
37
38
# File 'lib/wit/wit.rb', line 36

def confidence
  @confidence
end

#entitiesObject (readonly)

Returns the value of attribute entities.



36
37
38
# File 'lib/wit/wit.rb', line 36

def entities
  @entities
end

#intentObject (readonly)

Returns the value of attribute intent.



36
37
38
# File 'lib/wit/wit.rb', line 36

def intent
  @intent
end

#msg_bodyObject (readonly)

Returns the value of attribute msg_body.



36
37
38
# File 'lib/wit/wit.rb', line 36

def msg_body
  @msg_body
end

#msg_idObject (readonly)

Returns the value of attribute msg_id.



36
37
38
# File 'lib/wit/wit.rb', line 36

def msg_id
  @msg_id
end

#rawObject (readonly)

Returns the value of attribute raw.



36
37
38
# File 'lib/wit/wit.rb', line 36

def raw
  @raw
end