Class: Exa::Resources::Answer

Inherits:
Struct
  • Object
show all
Defined in:
lib/exa/resources/answer.rb

Overview

Represents an answer response from the Exa API

This class wraps the JSON response from the /answer endpoint and provides a Ruby-friendly interface for accessing the generated answer and citations.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(answer:, citations: [], cost_dollars: nil) ⇒ Answer

Returns a new instance of Answer.



10
11
12
13
# File 'lib/exa/resources/answer.rb', line 10

def initialize(answer:, citations: [], cost_dollars: nil)
  super
  freeze
end

Instance Attribute Details

#answerObject

Returns the value of attribute answer

Returns:

  • (Object)

    the current value of answer



9
10
11
# File 'lib/exa/resources/answer.rb', line 9

def answer
  @answer
end

#citationsObject

Returns the value of attribute citations

Returns:

  • (Object)

    the current value of citations



9
10
11
# File 'lib/exa/resources/answer.rb', line 9

def citations
  @citations
end

#cost_dollarsObject

Returns the value of attribute cost_dollars

Returns:

  • (Object)

    the current value of cost_dollars



9
10
11
# File 'lib/exa/resources/answer.rb', line 9

def cost_dollars
  @cost_dollars
end

Instance Method Details

#to_hObject



15
16
17
# File 'lib/exa/resources/answer.rb', line 15

def to_h
  { answer: answer, citations: citations, cost_dollars: cost_dollars }
end