Class: Exa::Responses::SearchResponse
- Inherits:
-
T::Struct
- Object
- T::Struct
- Exa::Responses::SearchResponse
- Defined in:
- lib/exa/responses/search_response.rb
Class Method Summary collapse
Class Method Details
.from_hash(hash) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/exa/responses/search_response.rb', line 13 def self.from_hash(hash) sym = Helpers.symbolize_keys(hash) new( request_id: sym[:requestId], resolved_search_type: sym[:resolvedSearchType], search_type: sym[:searchType], results: Array(sym[:results]).map { ResultWithContent.from_hash(_1) }, context: sym[:context], cost_dollars: normalize_cost(sym[:costDollars]) ) end |
.normalize_cost(value) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/exa/responses/search_response.rb', line 25 def self.normalize_cost(value) case value when nil nil when Numeric value.to_f when Hash Exa::Responses::Helpers.symbolize_keys(value) else value end end |