Class: BingSearchClient::Result
- Inherits:
-
Object
- Object
- BingSearchClient::Result
- Defined in:
- lib/bing_search_client/result.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#expanded_url ⇒ Object
readonly
Returns the value of attribute expanded_url.
Class Method Summary collapse
Instance Method Summary collapse
-
#expand_url! ⇒ Object
Instance method to get the real url insted of the url bing.
-
#initialize(body:) ⇒ Result
constructor
A new instance of Result.
Constructor Details
#initialize(body:) ⇒ Result
Returns a new instance of Result.
5 6 7 8 |
# File 'lib/bing_search_client/result.rb', line 5 def initialize(body:) @body = body @expanded_url = nil end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
3 4 5 |
# File 'lib/bing_search_client/result.rb', line 3 def body @body end |
#expanded_url ⇒ Object (readonly)
Returns the value of attribute expanded_url.
3 4 5 |
# File 'lib/bing_search_client/result.rb', line 3 def @expanded_url end |
Class Method Details
.build_from_array_response(raw_response:) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/bing_search_client/result.rb', line 10 def self.build_from_array_response(raw_response:) raw_response.map do |result_json_response| new(body: result_json_response).tap do |result| result. end end end |
Instance Method Details
#expand_url! ⇒ Object
Instance method to get the real url insted of the url bing
19 20 21 22 23 |
# File 'lib/bing_search_client/result.rb', line 19 def bing_url = URI(body[:url]) parsed_query = CGI::parse(bing_url.query) @expanded_url = parsed_query['r'].first end |