Class: BraveSearch::SummaryResult
- Inherits:
-
Object
- Object
- BraveSearch::SummaryResult
- Defined in:
- lib/brave_search/summary_result.rb
Instance Attribute Summary collapse
-
#raw_data ⇒ Object
readonly
Returns the value of attribute raw_data.
Instance Method Summary collapse
-
#deconstruct_keys(keys) ⇒ Object
Support pattern matching (Ruby 3+).
- #enriched_results ⇒ Object
-
#initialize(data) ⇒ SummaryResult
constructor
A new instance of SummaryResult.
- #key ⇒ Object
- #status ⇒ Object
- #summary ⇒ Object
- #to_h ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(data) ⇒ SummaryResult
Returns a new instance of SummaryResult.
7 8 9 |
# File 'lib/brave_search/summary_result.rb', line 7 def initialize(data) @raw_data = data end |
Instance Attribute Details
#raw_data ⇒ Object (readonly)
Returns the value of attribute raw_data.
5 6 7 |
# File 'lib/brave_search/summary_result.rb', line 5 def raw_data @raw_data end |
Instance Method Details
#deconstruct_keys(keys) ⇒ Object
Support pattern matching (Ruby 3+)
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/brave_search/summary_result.rb', line 33 def deconstruct_keys(keys) hash = { summary: summary, key: key, status: status, type: type, enriched_results: enriched_results } keys ? hash.slice(*keys) : hash end |
#enriched_results ⇒ Object
27 28 29 30 |
# File 'lib/brave_search/summary_result.rb', line 27 def enriched_results results = @raw_data.dig(:summarizer, :enriched_results) || [] results.map { |result| EnrichedResult.new(result) } end |
#key ⇒ Object
15 16 17 |
# File 'lib/brave_search/summary_result.rb', line 15 def key @raw_data.dig(:summarizer, :key) end |
#status ⇒ Object
19 20 21 |
# File 'lib/brave_search/summary_result.rb', line 19 def status @raw_data.dig(:summarizer, :status) end |
#summary ⇒ Object
11 12 13 |
# File 'lib/brave_search/summary_result.rb', line 11 def summary @raw_data.dig(:summarizer, :summary) || [] end |
#to_h ⇒ Object
44 45 46 |
# File 'lib/brave_search/summary_result.rb', line 44 def to_h @raw_data end |
#type ⇒ Object
23 24 25 |
# File 'lib/brave_search/summary_result.rb', line 23 def type @raw_data.dig(:summarizer, :type) end |