Class: Exa::Responses::CostBreakdown

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

Overview

Cost breakdown for a single request iteration (search + contents)

Class Method Summary collapse

Class Method Details

.from_hash(hash) ⇒ Object



32
33
34
35
36
37
38
39
40
# File 'lib/exa/responses/cost.rb', line 32

def self.from_hash(hash)
  return nil unless hash
  sym = Helpers.symbolize_keys(hash)
  new(
    search: sym[:search]&.to_f,
    contents: sym[:contents]&.to_f,
    breakdown: CostBreakdownDetail.from_hash(sym[:breakdown])
  )
end