Class: Exa::Responses::ContentsResponse

Inherits:
T::Struct
  • Object
show all
Defined in:
lib/exa/responses/contents_response.rb

Class Method Summary collapse

Class Method Details

.from_hash(hash) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/exa/responses/contents_response.rb', line 23

def self.from_hash(hash)
  sym = Helpers.symbolize_keys(hash)
  new(
    request_id: sym[:requestId],
    results: Array(sym[:results]).map { ResultWithContent.from_hash(_1) },
    context: sym[:context],
    statuses: sym[:statuses]&.map { ContentStatus.from_hash(_1) },
    cost_dollars: sym[:costDollars]&.to_f
  )
end