Class: Cloudflare::AI::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudflare/ai/result.rb

Instance Method Summary collapse

Constructor Details

#initialize(json_string_or_ruby_hash) ⇒ Result

Returns a new instance of Result.



5
6
7
# File 'lib/cloudflare/ai/result.rb', line 5

def initialize(json_string_or_ruby_hash)
  @result_data = parse_data(json_string_or_ruby_hash)
end

Instance Method Details

#errorsObject



21
22
23
# File 'lib/cloudflare/ai/result.rb', line 21

def errors
  result_data.dig(:errors)
end

#failure?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/cloudflare/ai/result.rb', line 17

def failure?
  !success?
end

#messagesObject



25
26
27
# File 'lib/cloudflare/ai/result.rb', line 25

def messages
  result_data.dig(:messages)
end

#resultObject



9
10
11
# File 'lib/cloudflare/ai/result.rb', line 9

def result
  result_data[:result]
end

#success?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/cloudflare/ai/result.rb', line 13

def success?
  success == true
end

#to_jsonObject



29
30
31
# File 'lib/cloudflare/ai/result.rb', line 29

def to_json
  result_data.to_json
end