Class: Exa::Resources::SearchResult

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

Overview

Represents a search response from the Exa API

This class wraps the JSON response from the /search endpoint and provides a Ruby-friendly interface for accessing search results and metadata.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(results:, request_id: nil, resolved_search_type: nil, search_type: nil, context: nil, cost_dollars: nil) ⇒ SearchResult

Returns a new instance of SearchResult.



16
17
18
19
# File 'lib/exa/resources/search_result.rb', line 16

def initialize(results:, request_id: nil, resolved_search_type: nil, search_type: nil, context: nil, cost_dollars: nil)
  super
  freeze
end

Instance Attribute Details

#contextObject

Returns the value of attribute context

Returns:

  • (Object)

    the current value of context



7
8
9
# File 'lib/exa/resources/search_result.rb', line 7

def context
  @context
end

#cost_dollarsObject

Returns the value of attribute cost_dollars

Returns:

  • (Object)

    the current value of cost_dollars



7
8
9
# File 'lib/exa/resources/search_result.rb', line 7

def cost_dollars
  @cost_dollars
end

#request_idObject

Returns the value of attribute request_id

Returns:

  • (Object)

    the current value of request_id



7
8
9
# File 'lib/exa/resources/search_result.rb', line 7

def request_id
  @request_id
end

#resolved_search_typeObject

Returns the value of attribute resolved_search_type

Returns:

  • (Object)

    the current value of resolved_search_type



7
8
9
# File 'lib/exa/resources/search_result.rb', line 7

def resolved_search_type
  @resolved_search_type
end

#resultsObject

Returns the value of attribute results

Returns:

  • (Object)

    the current value of results



7
8
9
# File 'lib/exa/resources/search_result.rb', line 7

def results
  @results
end

#search_typeObject

Returns the value of attribute search_type

Returns:

  • (Object)

    the current value of search_type



7
8
9
# File 'lib/exa/resources/search_result.rb', line 7

def search_type
  @search_type
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/exa/resources/search_result.rb', line 21

def empty?
  results.empty?
end

#firstObject



25
26
27
# File 'lib/exa/resources/search_result.rb', line 25

def first
  results.first
end