Class: Botiasloop::Tools::WebSearch::Result
- Inherits:
-
Object
- Object
- Botiasloop::Tools::WebSearch::Result
- Defined in:
- lib/botiasloop/tools/web_search.rb
Overview
Result wrapper for search results
Instance Attribute Summary collapse
-
#results ⇒ Object
readonly
Returns the value of attribute results.
Instance Method Summary collapse
-
#initialize(results) ⇒ Result
constructor
A new instance of Result.
- #to_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(results) ⇒ Result
Returns a new instance of Result.
48 49 50 |
# File 'lib/botiasloop/tools/web_search.rb', line 48 def initialize(results) @results = results end |
Instance Attribute Details
#results ⇒ Object (readonly)
Returns the value of attribute results.
46 47 48 |
# File 'lib/botiasloop/tools/web_search.rb', line 46 def results @results end |
Instance Method Details
#to_h ⇒ Object
58 59 60 |
# File 'lib/botiasloop/tools/web_search.rb', line 58 def to_h {results: @results} end |
#to_s ⇒ Object
52 53 54 55 56 |
# File 'lib/botiasloop/tools/web_search.rb', line 52 def to_s @results.map do |r| "#{r["title"]}\n#{r["url"]}\n#{r["content"]}" end.join("\n\n") end |