class KarakuriAi::Reply
Attributes
body[R]
Public Class Methods
new(json: nil, count: nil)
click to toggle source
# File lib/karakuri_ai/reply.rb, line 7 def initialize(json: nil, count: nil) @body = JSON.parse(json, symbolize_names: true) @count = count end
Public Instance Methods
count()
click to toggle source
# File lib/karakuri_ai/reply.rb, line 12 def count @count end
most_confident_text()
click to toggle source
# File lib/karakuri_ai/reply.rb, line 16 def most_confident_text if count == 1 @body[:card][:answers][0][:text] else @body.sort { |a, b| b[:confidence] <=> a[:confidence] }[0][:card][:answers][0][:text] end end